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

> I think the infinite-lookahead parsing rules should be:
> 
> * If the first token is an ident, then:
>   
>   * If it's a dashed-ident, followed by any amount of whitespace, followed by a colon: it's a custom property.

Do note that even though `--foo` is not a valid element name in either HTML or XML, the current element selector grammar allows it, since [it's defined in terms of `<ident-token>`](https://www.w3.org/TR/selectors/#type-selectors), which allows `--foo`: https://www.w3.org/TR/css-syntax-3/#ident-token-diagram . We should probably disallow it from the element selector grammar.

>   * If it's followed by any amount of whitespace and a colon, then look forward until you see either a semicolon (it's a property) or a {}-block (it's a rule).

Another optimization here would be that you only need futher lookahead if there's an ident or function token (or colon) after the colon.

> 1. Non-custom properties can never contain top-level {}-blocks. (They can put them in strings, or in functions, or in parens, whatever. Just not at the top.)

We could probably relax this further, and parse syntax where the entire property value is wrapped in braces as a declaration, which would allow things like:
```css
foo: {
 /* stuff */
}
```


-- 
GitHub Notification of comment by LeaVerou
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7961#issuecomment-1387539025 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 18:36:03 UTC