Re:Help choose the syntax for CSS Nesting
by lifthrasiir on Friday December 16, 2022 @02:41AM
(#34011891)
Pretty much late edit: in the second line `: has` to be `:has` with no whitespace (as CSS parsers do care about whitespaces in some contexts).
Re:Help choose the syntax for CSS Nesting
by somishere on Friday December 16, 2022 @08:38AM
(#34014354)
First up, anything starting with a .#* is a selector. Secondly, if you're selective about valid tokens then how many tokens are both a valid selector and property name? Probably custom only? And the number of times you'd find a pseudo selector on one of these? We're rapidly approaching extreme edge case territory here.
Also, looking at your second line: I would say the second part (starting at the semicolon before the h1), is invalidated by the semicolon. No need to lookahead or read up to the semicolon. The first part would always be evaluated first, up to the closing curly bracket. The second part would fail at the first character. I'm looking at this on a phone so maybe I've misread?
That said, the main problem is that the property syntax is overly forgiving, not that the nested rule syntax is faulty. Something akin to JS `use strict` should be able to restrict the property syntax enough to allow the nested rule syntax without unlimited lookahead.