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

Dropping & removes the ability to combine and reverse order of selectors so I wouldn't drop it. I think what we're suggesting here is to merely drop the **requirement** of the selector having to start with & (or to use @nest to allow it). Right now, the draft spec requires the selectors to start with & to pass the nesting requirement. Here's an example that is invalid:

```scss
.card {
    display: flex;
    .image& {
        display: block;
    }
}```

To make it valid, you need to prefix it with "@nest" like so:

```scss
.card {
    display: flex;
    @nest .image& {
        display: block;
    }
}
```

So what we're saying, in short, is to drop the @nest requirement and stop dancing around the current parsers limitation to allow authors to have a cleaner syntax without those two versions that could end up being confusing and allow the first example to be valid (if it works with @nest, why wouldn't it be able to work without?)

Sidenote, I personally don't care about selector concatenation. That, I can understand it adds a level of complexity that jumps into many more parsing hoops and issues and I don't think people absolutely really need it. BEM authors can use BEM with combinations instead of concatenations (.card__image would be .card.__image) and still be readable. If it was possible without being too complex and without adding too much parsing time to browsers, I would like it, but maybe we're not there yet. 

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


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

Received on Monday, 27 September 2021 14:23:39 UTC