Re: [csswg-drafts] [selectors-4] Allow * before a type selector (#8253)

With a few caveats for handling custom properties, the rule is just "try to parse a declaration; if that doesn't give you something valid, then parse as a rule instead". See <https://drafts.csswg.org/css-syntax/#consume-block-contents>.

With the resolution we got at TPAC (<https://github.com/w3c/csswg-drafts/issues/9317#issuecomment-1718966587>, not edited yet because I took the week off for COVID reasons), you can reliably early-exit even without grammar knowledge if (a) the first few tokens aren't `<ident> : ` or (b) you see a `{` that wasn't immediately preceded by a `:`. *With* knowledge of what properties are valid, you can virtually always early-exit after (a) when the ident isn't a property name. There's only a handful of cases when you'll even need to rely on the (b) exit (`font` and `marker` being the only ones I know of atm).

So there shouldn't be any perf-related reason to write your selectors as `:is(div)`; the parser will do just fine on its own.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8253#issuecomment-1732640421 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Sunday, 24 September 2023 18:37:34 UTC