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
{{ message }}
Repository navigation
Canonicalization rewrites [&_::pseudo-element]:* to **:[::pseudo-element]:*, which is a syntax error #20549
[::before] has no &, so it compiles to &:is(::before). Pseudo-elements aren't valid inside :is(), so it's a syntax error. In the Play link, the first dot is red and the second (the canonical form) stays black.
The same thing happens for every pseudo-element without an equivalent named variant, e.g. ::before, ::marker, ::-webkit-scrollbar and ::-webkit-search-cancel-button. It also happens with the child combinator: [&>::before] → *:[::before], which compiles to :is(.… > *):is(::before). Other cases come out right:
Pseudo-classes are fine: [&_:hover] → **:[:hover] compiles to :is(.… *):is(:hover), which is equivalent.
With a named variant it's fine: [&_::placeholder] → **:placeholder.
Expected: keep the &, i.e. **:[&::before]:text-red-500, which compiles to :is(.… *)::before, or leave the class unchanged. (**:[&::before]:text-red-500 is already treated as canonical.)
Cause: This was introduced in a41add9 (#19178, first released in v4.1.16). That commit widened the [&_X] / [&>X] rewrites from attribute selectors to any X starting with :. It also added a fallback that emits **:[X] / *:[X] when X has no named variant. That's correct for pseudo-classes, which are the only cases its tests cover (:first-child, :--custom). But ::before also starts with :, and the fallback drops the & that a pseudo-element needs.
changed the title [-]Canonicalization rewrites `[&_::pseudo-element]:*` to `**:[::pseudo-element]:*`, which matches nothing[/-][+]Canonicalization rewrites `[&_::pseudo-element]:*` to `**:[::pseudo-element]:*`, which is a syntax error[/+]on Oct 6, 2026
Activity
[-]Canonicalization rewrites `[&_::pseudo-element]:*` to `**:[::pseudo-element]:*`, which matches nothing[/-][+]Canonicalization rewrites `[&_::pseudo-element]:*` to `**:[::pseudo-element]:*`, which is a syntax error[/+]wongjn commentedon Oct 7, 2026
::beforehas a named variant, so really, the canonical form should be**:beforeabrahamguo commentedon Oct 7, 2026
@wongjn Technically no; as
&::beforedoesn't setcontentwhereasbefore:does.wongjn commentedon Oct 7, 2026
Ah yes, interesting distinction!
pricklymusic commentedon Oct 8, 2026
We need to update the canonicalization logic to detect pseudo-elements and prevent them from being extracted into a separate `:is
abrahamguo commentedon Oct 10, 2026
@pricklymusic Yes, that's exactly what @lazerg's PR does!
Canonicalization: keep `&` when moving a pseudo-element into `*` or `…