Re: [csswg-drafts] [css-nesting-1] Can we relax the syntax further? (#7961)

> disallow `<dashed-ident>` from `<type-selector>`

We could, but I don't see a great reason to do so. It's already not relevant for web languages, and if we restrict it, then theoretical future languages *can't* write a type selector like that at all. (Versus being able to, but having to be slightly careful.)

> look for an ident/function immediately after the colon

Yeah that's a reasonable early exit. It'll still require looking forward a lot of the time (especially if minifiers are used, which'll remove the space), but still.

> allow braces at the start of a decl value

Hm, yeah, this'll work, and preserve our ability to do something weird with braces in the future. It'll fall out of the previous point's behavior, in fact.

-------

Okay, revised:

* If the first token is an ident or function, then:
  * If it's a dashed-ident (or function with a dashed-ident name) , followed by any amount of whitespace, followed by a colon: it's a custom property. (This is theoretically infinite lookahead, but only if the author uses comments to create a bunch of  whitespace tokens. In all practical scenarios this is two tokens of lookahead.)
  * If the next tokens are any number of whitespace tokens, followed by a colon:
   * If the next token is an ident or function, then look forward until you see either a semicolon (it's a property) or a {}-block (it's a rule). (This is the main "infinite lookahead" point.)
   * Otherwise it's a property.
  * Otherwise, it's a rule.
* Otherwise, it's a rule.

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


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

Received on Wednesday, 18 January 2023 21:30:20 UTC