Re: [csswg-drafts] [css-nesting] Choose Nesting syntax — Option 3, 4 or 5? (#8248)

> Some people suggest making & mandatory at all times. We should open an issue on this (and replace this sentence with a reference).

Mandatory `&` in itself is not really interesting I think.
As @Loirooriol said this can be achieved with a linter, so I don't see the point of enforcing this in the specification unless if offers some advantage.

These cases are not helped by mandatory `&` :

- `div:has(> &)` compound selector with `&` in a functional pseudo
- `div &` complex selector with `&` not in the first compound

I am unsure what mandatory `&` is supposed to resolve.

------

> And before somebody asks, .foo & {... would be expressed as & .foo & {... in that case.

Using `&` as a prefix and as as reference to matched elements of the parent block is highly confusing and limiting.

```css
ul {
  & li & {
    /* style only ul elements that are in other ul li elements */
  }
}
```

Is the first `&` a prefix to indicate a style rule or is it a reference to `ul`?

--------

Can someone open an issue for this (as @LeaVerou indicated) and describe the benefits/details of mandatory `&`?

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


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

Received on Friday, 23 December 2022 19:13:24 UTC