Repository navigation
Canonicalization: don't unwrap :is(…) around a selector list in variant signatures - #20737
RobinMalfait wants to merge 1 commit into
Conversation
`createVariantSignatureCache` replaced `:is(…)` with its single child. When that child is a selector list, `&:is(.foo,.bar)` became `&.foo,.bar`, which in nesting means `&.foo, & .bar`. So `[&:is(.foo,.bar)]:flex` got the same signature as a `@custom-variant foo (&.foo, .bar)`, and canonicalized to it, while the two emit different CSS. Keep `:is(…)` when its single child is a `list` node. `:is(.foo)` → `.foo` and `:is(*:hover)` → `:hover` still unwrap.
[Medium impact] This PR appears safe to merge. Reviews (1) · Last reviewed commit: "Don't unwrap `:is(…)` around a selector ..." · Reviewed by Greptile |
|
No actionable comments were generated in the recent review. WalkthroughThe canonicalizer now unwraps Severity of issue fixed: Low Merge Risk:
|
This PR fixes a bug where
canonicalizeCandidatesreplaces an arbitrary variant with a custom variant that emits different CSS.createVariantSignatureCachereplaces:is(…)with its child when it has a single child. That child can be a selector list. Then&:is(.foo,.bar)becomes&.foo,.bar. In nesting, that means&.foo, & .bar, so.barturns into a descendant.Before this PR,
[&:is(.foo,.bar)]:flexcanonicalized tofoo:flex, but the two emit different CSS:[&:is(.foo,_.bar)]:flexand[&_:is(.foo,.bar)]:flexhad the same problem.Now we keep
:is(…)when its single child is a selector list.:is(.foo)→.fooand:is(*:hover)→:hoverstill unwrap.With this fix,
[&:is(.foo,.bar)]:flexcanonicalizes to[.foo,.bar]:flex. Both emit&:is(.foo, .bar).Test plan
canonicalize-candidates.test.ts. It fails without the fix (expected [ 'foo-or-bar:flex' ] to deeply equal [ '[.foo,.bar]:flex' ]).vitest runinpackages/tailwindcsspasses.pnpm run buildandpnpm changelog checkpass.