You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR is a followup of #18867, but this time we won't allow
`@custom-variant` to end with `-` or `_`.
The same reasoning applies here where Oxide doesn't pick this up but
Intellisense and Tailwind CSS' core does.
---------
Co-authored-by: Jordan Pittman <[email protected]>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
22
22
- Hide internal fields from completions in `matchUtilities` ([#18820](https://github.com/tailwindlabs/tailwindcss/pull/18820))
23
23
- Ignore `.vercel` folders by default (can be overridden by `@source …` rules) ([#18855](https://github.com/tailwindlabs/tailwindcss/pull/18855))
24
24
- Consider variants starting with `@-` to be invalid (e.g. `@-2xl:flex`) ([#18869](https://github.com/tailwindlabs/tailwindcss/pull/18869))
25
-
- Do not allow custom variants to start with a `-` ([#18867](https://github.com/tailwindlabs/tailwindcss/pull/18867))
25
+
- Do not allow custom variants to start or end with a `-`or `_`([#18867](https://github.com/tailwindlabs/tailwindcss/pull/18867), [#18872](https://github.com/tailwindlabs/tailwindcss/pull/18872))
26
26
- Upgrade: Migrate `aria` theme keys to `@custom-variant` ([#18815](https://github.com/tailwindlabs/tailwindcss/pull/18815))
27
27
- Upgrade: Migrate `data` theme keys to `@custom-variant` ([#18816](https://github.com/tailwindlabs/tailwindcss/pull/18816))
28
28
- Upgrade: Migrate `supports` theme keys to `@custom-variant` ([#18817](https://github.com/tailwindlabs/tailwindcss/pull/18817))
test('@custom-variant cannot contain dashes on its own',()=>{
3776
-
returnexpect(
3777
-
compileCss(css`
3778
-
@custom-variant- (&.dash);
3779
-
`),
3780
-
).rejects.toThrowErrorMatchingInlineSnapshot(
3781
-
`[Error: \`@custom-variant -\` defines an invalid variant name. Variants should only contain alphanumeric, dashes, or underscore characters and start with a lowercase letter or number.]`,
3782
-
)
3783
-
})
3784
-
3785
-
test('@custom-variant cannot contain multiple dashes on their own',()=>{
3786
-
returnexpect(
3787
-
compileCss(css`
3788
-
@custom-variant --- (&.dashed);
3789
-
`),
3790
-
).rejects.toThrowErrorMatchingInlineSnapshot(
3791
-
`[Error: \`@custom-variant ---\` defines an invalid variant name. Variants should only contain alphanumeric, dashes, or underscore characters and start with a lowercase letter or number.]`,
3792
-
)
3775
+
test.each([
3776
+
// Cannot be a dash on its own
3777
+
[`@custom-variant - (&);`],
3778
+
// Cannot be multiple dashes on their own
3779
+
[`@custom-variant --- (&);`],
3780
+
// Cannot be an underscore on its own
3781
+
[`@custom-variant _ (&);`],
3782
+
// Cannot be multiple underscores on their own
3783
+
[`@custom-variant ___ (&);`],
3784
+
3785
+
// Cannot start with a dash
3786
+
[`@custom-variant -foo (&);`],
3787
+
[`@custom-variant --foo (&);`],
3788
+
// Cannot start with an underscore
3789
+
[`@custom-variant _foo (&);`],
3790
+
[`@custom-variant __foo (&);`],
3791
+
3792
+
// Cannot end with a dash
3793
+
[`@custom-variant foo- (&);`],
3794
+
[`@custom-variant foo-- (&);`],
3795
+
// Cannot end with an underscore
3796
+
[`@custom-variant foo_ (&);`],
3797
+
[`@custom-variant foo__ (&);`],
3798
+
])('@custom-variant must have a valid name',(input)=>{
0 commit comments