Skip to content

Conversation

@RobinMalfait
Copy link
Member

This PR fixes an issue where we didn't always correctly validated invalid CSS variables when using the CSS variable shorthand syntax.

This PR fixes that by ensuring we start with --. We can't validate that the variable exists at runtime, but we can validate if it looks like a valid CSS variable.

We can go a step further by validating if the CSS variable is valid syntax (e.g.: all characters are valid), but we can introduce this if this is causing actual issues in projects.

p-(a-b)

Used to compile to:

.p-\(a-b\) {
  padding: var(a-b);
}

But not anymore.

@RobinMalfait RobinMalfait requested a review from a team as a code owner January 23, 2025 12:22

expect(run('bg-(color:my-color)', { utilities })).toMatchInlineSnapshot(`[]`)
})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add tests for stuff like bg-foo/(bar) to make sure it's thrown out too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good call!

@RobinMalfait RobinMalfait merged commit 193fc60 into next Jan 27, 2025
5 checks passed
@RobinMalfait RobinMalfait deleted the fix/validate-css-variable-shorthand branch January 27, 2025 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants