Re: [csswg-drafts] [css-nesting-1] Syntax Invites Errors (#7834)

One thing I'd like to point out is that in the code examples @tabatkins posted, using `@nest` as the parsing switch appears to be preferable, as it looks more consistent because everything is a descendant selector.

However, in real nesting use cases, the first few rules are often (though of course not always) specifying variations of the base rule, e.g. `&:disabled`, `&:nth-child(odd)`, `&.foo` etc, so you have the ampersand there *anyway*. E.g.:

```css
section {
 declarations;

 &.main {
  declarations;
 }

 h1 {
  declarations;
 }

 p {
  declarations;
 }

 ...
}
```

so the parsing switch often comes naturally, whereas with `@nest` it needs to be explicit in all cases and adds a fair bit of noise. I'm fine with this noise being opt-in, for authors that want it, but it should not be mandatory.

Note that this is exactly how the above code would have been written in Sass (which was designed without our parsing constraints and thus is IMO the most natural syntax for this, so the closer we can get, the better).


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


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

Received on Wednesday, 5 October 2022 22:42:31 UTC