Re: [csswg-drafts] [css-nesting-1] Name, terminology, and nesting selector misnomers are footguns (solution proposed) (#8329)

> It's @nest, no?

No, that was an earlier version of the spec. There is no at-rule anymore in the current spec.

> If it already is as you say, it's not being indicated in that spec right now. That it seems to enforce root + descendants only for scopes

The `:scope` pseudo-class can appear anywhere in the selector (of style rules inside of `@scope`). The elements matched by that selector have to be the scoping root or one of its descendants, due to being "scoped", but any other components of the selector can match anything in the tree.  For example, `@scope (div.foo) { :root.bar p {...}}` will match `p` elements inside a `div.foo` element *if* the root element (which is definitely outside the scope) has a `.bar` class. There's no implicit prepending of `:scope` to anything; the selectors are evaluated against the whole page, and then we just filter the results according to the scope.

> It used to have more permissive meanings and scope-relative allowed the meaning I'm giving here, so I guess I'm making an argument for that being allowed again.

It turned out that we didn't actually want the "scope-relative" meaning anywhere. `querySelector()` doesn't use it, `@scope` doesn't use it; being able to refer to element outside your scope is just too useful of an ability to throw away. Nesting doesn't use it either - it does something *vaguely similar* but still very distinct, allowing the selector to match *anything on the page* with no required relation to the parent selector (if you write your selector accordingly).

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


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

Received on Thursday, 26 January 2023 00:25:01 UTC