[csswg-drafts] [css-nesting-1] Clarify valid position of `&` in a selector (#9940)

cdoublev has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-nesting-1] Clarify valid position of `&` in a selector ==
CSS Nesting does not clearly define where `&` is allowed to appear in a selector. In Chrome/FF, these selectors are all invalid:

  - `html|&`
  - `html&|*`
  - `#&id`
  - `.&class`
  - `[&]`
  - `[attr=&]`
  - `[attr=value &]`

While the position of `&` does not make a difference in its behavior, it should only match `<type-selector>` and `<subclass-selector>` in [`<compound-selector>`](https://drafts.csswg.org/selectors-4/#typedef-compound-selector).

---

I would also like to suggest to define this again (cf. #7503):

  > An invalid selector remains invalid when some of its parts are nested.

In Chrome/FF, the nested rule in `::before, div { &:first-child {} }` is valid whereas the version without nesting, `::before:first-child, div:first-child {}` is not (because `:first-child` is [not allowed](https://drafts.csswg.org/selectors-4/#pseudo-element-states) to be compounded to `::before`).

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9940 using your GitHub account


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

Received on Tuesday, 13 February 2024 08:37:09 UTC