- From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
- Date: Wed, 01 Mar 2023 21:09:29 +0000
- To: public-css-archive@w3.org
> Weak `@scope` ends up weaker than nesting in almost all cases, yet is a heavier syntactic construct. Yes, it's weaker, in part, BECAUSE it's a heavier construct. Nesting is pretty much just sugar. It's intentionally *extremely* lightweight in syntax, and does as little as possible to disturb specificity. In general there shouldn't be a difference between writing as `.foo:hover, .bar:hover {...}` and `.foo, .bar { &:hover {...}}`, it should just be an authoring choice about what's clearer. Scoping is heavier weight, there's more of a visual disconnect between the scope selectors and the contained rules. This happens to also be exactly what we want - if you're theming a construct in multiple ways, using presumably identical selectors in each, having the scope-start selector not fold into the contained rules' specificities means it doesn't matter *how* you indicate the theme set. You might have a default on `section`, a `.light` or `.dark` override, and a more specific `#foo` or `.sidebar > section` for particular cases. All of them act identically, with whatever the closest scoping element is determining which one wins. This "ignore specificity of the context selector, just rely on the nested selectors from whichever block's context is closest" could *also* be achieved with strong scoping, of course. The point is just that this difference from nesting's relationship with its "parent" selector is intentional. > Weak scoping is something that probably is more useful than descendant selectors in almost all cases, so if we're introducing it it should be easy to use it everywhere instead of descendant selection. It is, with the `>>` combinator. To be fair, that's not *easier* than the existing descendant combinator, but we're kinda boxed in by our past choices there. It is at least definitely *easy*. > We're tying the ability to floor a selector to applying weak scoping. But it's independently useful. Sure, but that argues *much more* strongly against strong scoping. Weak scoping is weak *enough* that if you're using an @scope solely for a lower boundary, it won't really affect much - remember, the *only* thing it does is break ties that would otherwise be resolved by *source order*, the final and most arbitrary of cascading criteria. And if you really *do* want to use it *solely* as a lower boundary protector, you can easily do so - `@scope (:root) to (.lower-bound) {...}` works, and renders the proximity aspect (even more) toothless. -- GitHub Notification of comment by tabatkins Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6790#issuecomment-1450850816 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 1 March 2023 21:09:31 UTC