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
If a parent style uses a selector list and a child style uses both the parent reference (&) and a pseudo class, that pseudo class isn't present on all parent selectors as expected.
Produces .asdf > input, .asdf .foo > input:focus {...} on the last selector only, and not .asdf > input:focus, .asdf .foo > input:focus {...} on all selectors as expected.
The text was updated successfully, but these errors were encountered:
whiteinge
changed the title
Selector list parents plus psudo class children don't apply to all parent selectors
Selector list parents plus pseudo class children don't apply to all parent selectors
Nov 9, 2021
Oh, thanks for the link. I did search the issues before opening this but 'selector list' and 'pseudo class' don't appear in those others and I didn't think to just search for 'comma' 😛 .
I can definitely appreciate not wanting to introduce a parser. That said, I do wonder if we could get by with a very naive one since, I think, we only care about top-level selector lists. Offhand:
Only parse selectors, not properties;
Avoid parsing anything inside a CSS function;
(Probably?) avoid anything inside an attribute selector (unsure if/where commas can appear there);
Edit: a few pseudo-class functions support selector lists as arguments -- :is(), :where(), and more in the Selectors 4 addition.
Can you think of anything I'm overlooking? I wonder if it could be as simple as splitting on any commas outside pairs of ( and [ -- and maybe " and ' too (or will those always appear inside one of the first two?). I'll poke around the spec and some existing parsers.
If a parent style uses a selector list and a child style uses both the parent reference (
&
) and a pseudo class, that pseudo class isn't present on all parent selectors as expected.E.g.:
Produces
.asdf > input, .asdf .foo > input:focus {...}
on the last selector only, and not.asdf > input:focus, .asdf .foo > input:focus {...}
on all selectors as expected.The text was updated successfully, but these errors were encountered: