Re: [csswg-drafts] [css-scoping] Proposal for light-dom scoping/namespacing with re-designed `@scope` rule (#5809)

The CSS Working Group just discussed ``[css-scoping] Proposal for light-dom scoping/namespacing with re-designed `@scope` rule``.

<details><summary>The full IRC log of that discussion</summary>
&lt;dael> Topic: [css-scoping] Proposal for light-dom scoping/namespacing with re-designed `@scope` rule<br>
&lt;dael> github: https://github.com/w3c/csswg-drafts/issues/5809<br>
&lt;dael> miriam: I have slides, but talk through without?<br>
&lt;miriam> https://slides.oddbird.net/csswg/f2f2102/#slide-26<br>
&lt;dael> miriam: Link ^<br>
&lt;dael> [trying to see if miriam can present]<br>
&lt;dael> miriam: I'll talk through them<br>
&lt;dael> miriam: There has been several threads open about having a scoping in css<br>
&lt;dael> miriam: There was even attempt in 2014 to spec it. not impl.<br>
&lt;dael> miriam: Looking into it I found differences with shadow dom. Proposal is what is see is missing from shadow dom.<br>
&lt;dael> miriam: Main goals are avoiding naming conflicts and expressing memebership in a scope. Similar to what shadow dom does which gives us scope and slots. Different from ancestor b/c lower bounderties. It actually belongs to the component<br>
&lt;dael> miriam: A lot of tools out there try and do this manually. Putting together special selectors<br>
&lt;dael> miriam: Other part is trying to capture sense of proximity. A light and dark theme and I need to style links in those. If I use descendant selector the second definition take precesendce when selected. What I want is the one that is closer.<br>
&lt;fantasai> [slide 32]<br>
&lt;fantasai> [slide 33]<br>
&lt;dael> miriam: Why not shadow dom? Basic answer is shadow dom encapulation is high impact and dom centered. Element itself is the scope and that's hard bounderies in the dom. Strong isolation of bounderies.<br>
&lt;fantasai> [slide 34]<br>
&lt;dael> miriam: High power in the cascade as well. It overrides specificities<br>
&lt;fantasai> [slide 35]<br>
&lt;dael> miriam: Interesting proposals to improve, but don't resolve central issues. I think declaritive shadow dom is interesting. But not the same thing as we're trying to solve with views etc.<br>
&lt;dael> miriam: I sometimes want lower bounds, outer bounds. But I want to do that and it's a presentational decision, not semantic. I don't want it tied to dom elements. I want overlap. I want to say what's in or out<br>
&lt;fantasai> [slide 38]<br>
&lt;TabAtkins> q+ when Miriam is done to express support<br>
&lt;leaverou> q+<br>
&lt;TabAtkins> qq+<br>
&lt;dael> miriam: All these tools do it lower impact. It's reused across leements. Priority is handled through ownership rather then specificity<br>
&lt;leaverou> q-<br>
&lt;leaverou> q+<br>
&lt;fantasai> [slide 40]<br>
&lt;fantasai> [slide 41]<br>
&lt;miriam> https://www.irccloud.com/pastebin/MtGSIIPT/<br>
&lt;dael> miriam: Prop bringing back scope rule and scope pseudo class. Proposal is a syntax like &amp;<br>
&lt;dael> miriam: We get @scope and add a selector for outer bounds. Optionally add a to() with any number of lower bounderies. Anything within the rule would scope between selectors<br>
&lt;dael> miriam: Scope selector is the root. It's implied when not used<br>
&lt;fantasai> [slide 42]<br>
&lt;fantasai> [slide 43]<br>
&lt;dael> miriam: I have more details about exactly how I see boundry and selector matching working. Gone through tag review on how it would work. Final piece is this triggers proximity as part of cascade. When 2 scopes overlap inner scope is the fallback to specificity. When they're equal internal scope takes presedence.<br>
&lt;dael> miriam: Some talk about being able to scope to a donut. Is it useful to have it as a selector in it's own right. Interesting and could look more<br>
&lt;astearns> ack TabAtkins<br>
&lt;Zakim> TabAtkins, you wanted to react to a previous speaker<br>
&lt;dael> TabAtkins: I'm very happy to see this. Was happy to work with miriam early on. We tried to do light dom scoping earlier but that was substantially different. It was trying to interact similar leverl of intrusiveness as shadow dom<br>
&lt;astearns> ack leaverou<br>
&lt;dael> TabAtkins: This being a low thing is a really great and useful tool that compliments shadow dom and what we're doing. I'm a big fan of it<br>
&lt;dael> leaverou: I would like to agree with TabAtkins this is highly needed. I support it<br>
&lt;dael> leaverou: Elaborating on my point, I think propo consists of 2 parts. Name spacing use cases which are nesting within this new scope rule and the prozimity prioritization. And then there's the donut scope syntax. Anything related to selection logic isbetter in selectors. That gives it a JS API which gives you access to frequently needed queries<br>
&lt;dael> leaverou: Worth exploring how the donut scope could be done through selectors syntax so @scoping can just have the scoping and not the selection<br>
&lt;dael> leaverou: Does that make sense?<br>
&lt;dael> fantasai: You're prop selector in addition to @scope where selctor is a limit on what's selected?<br>
&lt;dael> leaverou: Yes<br>
&lt;argyle> like `@scope .tabs - .panel {}` like this? where the dash is showing a range?<br>
&lt;dael> fremy: Makes a lot of sense to me<br>
&lt;fantasai> s/selected/selected, but doesn't affect the cascade/<br>
&lt;Rossen_> q?<br>
&lt;dael> florian: Seems worht exploring. Since interested in both parts, I'd like to first express support for the whole thing. We'll take everything here and then as we take this poss try to do donut in selectors. Don't insist on the donut thing to take this<br>
&lt;astearns> ack fantasai<br>
&lt;dael> leaverou: Both problems need solving<br>
&lt;TabAtkins> Hm, I'm not sure how we would work a lower-boundary into the normal selector syntax<br>
&lt;dael> fantasai: Question I have is, I want to understand impact on specificity. Previous @scope proposal which didn't have lower bound. Other difference is specificity, if you have more specific selector outside it overrides in the scope. In previous prop if you're inside a scope it overrides everything outside.<br>
&lt;dael> miriam: That's right<br>
&lt;TabAtkins> Currently, @scope basically *is* just a selector (allowing nesting)<br>
&lt;dael> fantasai: Can you explain the reasoning behind why this is the appropriate choice?<br>
&lt;dael> miriam: One thing, going back a ways as I teach CSS people expect this to be the default fallback. People are surprised by source order being the fallback. That was in my mind<br>
&lt;florian> q+<br>
&lt;dael> miriam: Also this is how all the tools currently work. Feels like it works well to me. Not trying to isolate strongly, trying to keep things from getting out, not from getting in<br>
&lt;dael> miriam: Tools do it with an added attribute now, but that only increases spec by a small amount<br>
&lt;dael> fantasai: This has less impact. Concerned it would cause...not give same results in a lot of cases. not convinced. When you add a class, you'd have to add more specificity.<br>
&lt;leaverou> +1 to fantasai's concerns. If it can be overridden by rules outside the scope, it becomes very similar to nesting which we know doesn't solve these problems<br>
&lt;dael> miriam: Except that the proposal has the scope root selector being added to all selector in scope so it's same as single attribute in most cases, but could be more powerful. Set root selector to ID you're adding the id to seelctor to everything inside. Can create higher weight but you have more control. Only proximity part is lower<br>
&lt;dael> fantasai: spec of selector in @scope condition is added to all selectors within scoped block<br>
&lt;dael> miriam: Right<br>
&lt;dael> fantasai: That wasn't clear. I don't hitnk that's a good design. The way you select element you want to be scoped shouldn't have effect on how specific selector in scope are. If you switch class to ID it can completely distroy relationship between selectors.<br>
&lt;TabAtkins> q+<br>
&lt;dael> fantasai: Where this fits in cascade I'm interested to think about. I don't htink choice of selector in @scope should have effect on cascade<br>
&lt;astearns> ack TabAtkins<br>
&lt;dael> TabAtkins: What I like about miriam design is it is virtually identical to specificity landscape, including with nesting. That means that it's as familiar as specificity in existing css including the scope inheriting into nested selectors<br>
&lt;dael> TabAtkins: You can override it with no specificisty selector. That would achieve same effect w/o specificity. By default you get today's behavior. That has problems, of course, but because we're in todya's model anything we do in the future doesn't have more to worry about. It's the existing model and wil interoperate<br>
&lt;astearns> ack florian<br>
&lt;dael> florian: I don't have a strong view on issue we've been discussion, but not that concerned. Compared to last time we tried this it's easier b/c less problems. We have cascade layers and shadow dom. As miriam pointed out main goal is prevent styles from leaking out. We need tor esolve conflicts, but primary goal is leaking out<br>
&lt;dael> florian: If you want strong isolation maybe you should use shadow dom. If you want to make sure you win you have cascade layers. We need to solvet he discussion, but unlike last time since we're not trying to solve all the problems it doesn't concern me as much<br>
&lt;dael> fantasai: I have strong reservations about the proposal<br>
&lt;nicole> q+<br>
&lt;dael> astearns: Are they about the specificity for the rules inside the block?<br>
&lt;TabAtkins> Yup, recognizing that we're already solving the "figure out which large set of styles wins" in other ways means we can focus this one on the much simpler problem of "lower bound protection" (and, for giggles, letting us give a weak notion of proximity to specificity).<br>
&lt;astearns> ack nicole<br>
&lt;dael> fantasai: Basically, everything except syntax. Also where it fits into cascade. Feel strongly spec of root selector should not be a factor in cascade. Not convinced way defined to itneract with specificity is what we want. Possible it is and I don't understand use cases, but I don't think so.<br>
&lt;dael> nicole: Speaking to use in design systems. You would end up with simple seelctor in root selector<br>
&lt;dael> nicole: I would have expected that as a part of specificitly b/c how nesting works in sass<br>
&lt;leaverou> q+<br>
&lt;fantasai> s/I don't think so/based on what I know, I don't think this is right/<br>
&lt;astearns> ack leaverou<br>
&lt;dael> nicole: Case on more complex selector in root would be more rare. I would expect they want something specific and fremy said that would be better achieved with layers. The interaction of the 2 makes sense<br>
&lt;fantasai> s/Also where/Where/<br>
&lt;dael> leaverou: Separate nesting spec that's supposed to do same as nesting in sass. If they do similar things with slight differences it will be confusing. I agree with some of fantasai concerns. WE know nesting doesn't solve scoping use cases. If things outside scope can leak in worried it won't address cases<br>
&lt;TabAtkins> Contra fantasai, I feel *strongly* that the root selector needs to be figured into the nested styles, because otherwise the selectors will *often* be too weak. Keeping those selectors weak *when they would auto-win anyway* (as our earlier @scope attempt did) is fine, but if we're working within the standard specificity wars, letting the container's selector add in is necessary.<br>
&lt;dael> fantasai: I think you want things to leak in, but leak in at a lower priority<br>
&lt;dael> leaverou: That's what I meant<br>
&lt;dael> fantasai: Prop here fusses with spec and scoping is a fallback. Previous scoping said it was higher than specificity so inner scope would win if there and outer would take effect. Shadowdom the outer scope wins.<br>
&lt;dael> fantasai: Both cases are different. Question is how does scoping interact with specificity<br>
&lt;fremy> I agree with TabAtkins here<br>
&lt;dael> TabAtkins: WE're solving problem of how to worry about larger scale conflicts with layers so we don't have to care as much here.<br>
&lt;dael> fantasai: I think layers helps a lot, but not quite the same. But yeah, can create a layer for every component. Seems overkill<br>
&lt;dael> leaverou: Layers are supposed to contain enitre library, not every component<br>
&lt;dael> TabAtkins: I don't htink you'll be worrying at that level<br>
&lt;dael> fantasai: Example: I have a sidebar in my page and want it to have a different color. Inverse contrast color. I have rules setting link color heading color etc. Need to override them all in my sidebar. I override the link and say it's light.<br>
&lt;dael> fantasai: Overall outer page has slightly different colors for links in a list. B/c that's higher specificity it overrides the sidebar.<br>
&lt;argyle> Sime Vidas showing donut scoping with complex `:not()` https://css-tricks.com/weekly-platform-news-focus-rings-donut-scope-ditching-em-units-and-global-privacy-control/#the-enhanced-css-not-selector-enables-donut-scope<br>
&lt;dael> fantasai: So it doesn't solve the scoping problem b/c specificity<br>
&lt;leaverou> argyle: I've made this point too, but this fails with nested structures<br>
&lt;dael> TabAtkins: You're right it does not solve. You solve it using standard specificitly mechanisms or if this is a page specific modification that's what layers is designed to do. Let you separate general styles from specific styles that need to win at all costs. We've solved that<br>
&lt;dael> fantasai: It's not nec page specific. It could be for my whole site<br>
&lt;dael> florian: What's wrong with a layer<br>
&lt;dael> fantasai: Rest of page could have layers and now they're siblings. It's not about the loading, it's about am I in a sidebar b/c if I am they need to be more important. That's hierarchy, not which stylesheet wins<br>
&lt;fantasai> s/siblings/sibling layers, and ordering matters/<br>
&lt;leaverou> argyle: I've written more about how it fails with nested structures here: https://github.com/w3ctag/design-reviews/issues/593#issuecomment-769351277<br>
&lt;dael> TabAtkins: I don't agree entirely. In some cases yes, but in many cases it's not. Complexifying this by adding another strong kind of scoping will add a ton of complications. Solving in this weak way that melds cleanly and goes with the general approach is better<br>
&lt;dael> astearns: miriam I think you should take the strong opinions as encouragement. That everyone is digging in and has strong opinions and expressing concerns is an indication we should continue work.<br>
&lt;dael> astearns: I don't think we'll be able to resolve to officially work on this right now, but I think we can get there<br>
&lt;TabAtkins> leaverou, argyle: Yeah, current selectors are definitely just too weak to handle lower bounds.<br>
&lt;dael> miriam: Yes, and I was expecting this to be contentios because there are use cases all along the spectrum. That's been a challenge with scope. I went weak intentionally. There are strong pieces out there so I thought I'd go the other direction to balance out the use cases.<br>
&lt;dael> astearns: I think that's all the time we can give to this today<br>
&lt;fantasai> TabAtkins, this is adding something that's "almost the same as nesting but not quite in small ways", as Lea noted. That's more confusing than adding strong scoping that works the opposite of shadow DOM.<br>
&lt;dael> astearns: I don't know how much time you can spend on this miriam but feel free to create something in spec form and make separate issues for the separate concerns.<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5809#issuecomment-795831351 using your GitHub account


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

Received on Wednesday, 10 March 2021 18:01:29 UTC