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

For what it's worth, you can essentially just take the "required `@nest;`" proposal, replace the `@nest;`s with `} @nest {`, and you've got François' proposal. If you don't like how the indentation goes back a level before nesting (which I would understand and agree with) the you can simply pretend like `@nest;` is a thing, but write it as `} @nest {`.

This (François' proposal):
```css
a {
    color: blue;
}
@nest {
    &:hover {
        color: red;
    }
}
```
versus this (François' proposal, re-formatted):
```css
a {
    color: blue;
    } @nest {
    &:hover {
        color: red;
    }
}
```
versus this (the `@nest;` proposal):
```css
a {
    color: blue;
    @nest;
    &:hover {
        color: red;
    }
}
```
The benefit of `} @nest {` over `@nest;` is that there is no parser mode switch, and we can re-use the syntax construct we're using for `@else`.

> To me, the mixing of declarations and selectors is significantly more confusing than using a different block.

I disagree with this, but this is just a personal preference; I believe it's quite easy for humans to tell declarations apart from selectors, and even if it wasn't, we use syntax highlighters to help us with this type of thing. The good thing about the `} @nest {` is that we can choose which we like more, and we can choose to dedent the `@nest` block to match the selector for the block it's nesting for, or we can choose to indent it and level the `} @nest {` with the declarations instead, like you would with `@nest;`.

> Can we just rule these out early (and those that introduce extra levels of nesting that have been ruled out in https://github.com/w3c/csswg-drafts/issues/4748)

That proposal did indeed rule out an _extra level_ of nesting, but François' proposal doesn't do that at all. It introduces a separate block for the nested styles _without_ introducing another nesting level. It's actually quite clever. And, let's try to give suggestions a fair chance - this is an open discussion and I think everyone's proposals deserve to be looked at and considered. If it does indeed fail to meet some criteria we've previously mentioned, we can rule them out. But this one, I don't think does that.



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


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

Received on Friday, 14 October 2022 09:02:31 UTC