Re: [csswg-drafts] [selectors][css-nesting] Move nest-containing and nest-prefixed selector definitions to Selectors (#5745)

The goal is to give the `&` selector a consistent meaning, no matter where you use it. Rather than treating it as a special-case syntax - only for direct selector nesting, and an error everywhere else - we treat it as a first class selector with a built-in meaning of 'the current nesting context'. Roots and scopes are nesting contexts, so we should support those as well. This makes `&` behave more like any other selector, valid anywhere selectors are valid. Which is useful, because it often makes sense to move selectors from one context to another (especially between nesting and scoped contexts). If they still have a reasonable meaning, they should continue to work.

So this isn't really about a special-case 'alias' between two selectors - it's just that _in this case, the selectors refer to the same element_. The `&` always refers to the nesting context, no matter how that context is generated. In both root and scoped contexts, we know what nesting context we're in, so we have a reasonable interpretation of the `&` selector. At the root level, the nesting context is the `:root` element (which also happens to be the default `:scope`. Inside a scope rule, the nesting context is also the `:scope` - but may or may not be the `:root`. 

As far as selectors are concerned, scope is already just fancy nesting. At the root level `:scope`, `:root`, and `&` all refer to the root element. Selector nesting updates the meaning of `&`. The scope rule updates the meaning of both `:scope` and `&`. Both maintain their meaning, wherever you use them - and sometimes those meanings overlap.

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


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

Received on Friday, 7 October 2022 17:46:15 UTC