Re: [csswg-drafts] [css-nesting-1] Should prefixing nested selectors be mandatory? (#8270)

Requiring `&` will not work, since the `&` character will be used for usecases like this:
``` 
section {
  article  &  {
     color: black;
  }
}
```
which results in `article section { color: black; }`.  `section { & article  &  {` would result in `section article section  {`.

There has been discussion of using a different symbol. Keep `&` as is. And use something else, `@`, `*`, `@nest` instead for what's being proposed here.  Like this: `section { * article  &  {` — see #8253

The CSSWG has discussed mandating a prefix (whatever the character) quite a bit already. And settled on no — because we value author's ability to more easily copy & paste code in/out of a nested context.

All that said, I believe we should not make prefixing nested selectors mandatory because of the Robustness principle (also known as Postel's law): "be conservative in what you send, be liberal in what you accept".

Web technology has been designed with a set of principles in mind, to rely on when debating questions exactly like this one. Some developers want the mandatory symbol, others do not. So which is the right choice? We could debate pros & cons forever and still not agree. So let's define some underlying principles to help us guide decisions. 

According to the Robustness principle, CSS should lean towards _more_ flexibility in how authors write their selectors, not less. If they want to always use a `&`, great. If they don't, great. It's up to them. The browser should be liberal in what it accepts. 

I do not believe we should violate the Robustness principle for this case. 

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


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

Received on Tuesday, 3 January 2023 19:43:45 UTC