- From: Keith Grant via GitHub <sysbot+gh@w3.org>
- Date: Mon, 28 Jan 2019 17:05:35 +0000
- To: public-css-archive@w3.org
> The reason why the `scoped` attribute idea was abandoned is that, in contrast to ShadowDOM, it didn't come with any lower boundary. This means that styles affect an entire subtree rather than a single "component". In fact this is not different from prefixing every selector with a unique id eg. `.foo { }` becomes `#scope-unique-id .foo {}`. I don’t think this is accurate. When scope was in the spec, it was defined such that inner scopes overrode outer scopes, regardless of selector specificity. For example, given: ```css /* in one scope */ .foo { color: blue; } /* in another scope */ .bar { color: red; } ``` A `foo` inside a `bar` would be blue, and a `bar` inside a `foo` would be red. Which addresses *precisely* the problem CSS-in-JS seeks to solve, and would be hugely beneficial. I also thought the final version of the spec, which relied on a `@scope` at-rule rather than an html attribute was much better. ([Here’s my write-up on that](https://keithjgrant.com/posts/2016/06/save-scoped-css/)) -- GitHub Notification of comment by keithjgrant Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3547#issuecomment-458215743 using your GitHub account
Received on Monday, 28 January 2019 17:05:36 UTC