Re: [csswg-drafts] [css-nesting-1] Invalid nested selectors (#7503)

> As currently written, `::before&` is invalid as the selectors grammar only allows `<pseudo-class-selector>` after it.

Please note that with `&::before`, the problem remains, depending on how you expect it to desugar, which seems to be by "moving" `&` to the end of the selector:

  > `type1 { &type2 {...}}` is indeed perfectly valid, equivalent to `type2:is(type1) {...}`. [...]
  >
  > `svg { &|rect {} }` is also valid, equivalent to `|rect:is(svg)` [...]

`&::before` is a valid `<relative-selector-list>` but `::before:is(:root)` (desugared from `:root { &::before {} }`) is invalid, because `::before:root` is invalid, according to [Selectors](https://drafts.csswg.org/selectors-4/#pseudo-element-states):

  > Certain pseudo-elements may be immediately followed by any combination of certain pseudo-classe [...]. This specification allows any pseudo-element to be followed by any combination of the logical combination pseudo-classes and the user action pseudo-classes. [...] Combinations that are not explicitly allowed are invalid selectors.
  >
  > NOTE: The logical combination pseudo-classes pass any restrictions on validity of selectors at their position to their arguments.

However the examples in the spec seems to remember its position. This is another reason why I commented:

  > First, I think an example showing that there is no difference between `div { &:hover {} }` and `div { :hover& {} }` would be usefull (whereas only `div:hover` is valid).

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


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

Received on Friday, 24 February 2023 09:19:07 UTC