Re: [csswg-drafts] [css-nesting] Syntax suggestion (#4748)

The more I look at the current syntax, the more convinced I am that there's no 'inconsistency' to worry about, and the 'double syntax' pretty cleanly reflects two different tools that are both useful in nested CSS. And these two types of nesting are actually pretty clear to authors:

- Most nesting involves _adding to the end of the selector chain_. That's the highest priority use-case, and it works as expected, using selectors that start with `&`.
- Some more advanced nesting use-cases involve _adding to the start of the selector chain_, or _around_ it. In those cases, the `@nest` rule is used.

Sass has a very similar special-nesting feature in the [`@at-root`](https://sass-lang.com/documentation/at-rules/at-root) rule. It does basically the exact same thing as the proposed `@nest`. The main difference is that Sass doesn't require the at-rule _as consistently_ when doing advanced nesting.

While it's true that CSS has to do this for obscure internal parsing reasons, the resulting logic is not at all obscure, or arbitrary, or difficult to learn & teach. It's actually more clear than the Sass logic, since it aligns more directly with a clear semantic difference that authors already think of as two different 'types' of nesting: appending vs manipulating.

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


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

Received on Friday, 2 September 2022 16:11:57 UTC