Re: [WICG/webcomponents] "open-stylable" Shadow Roots (#909)

> It would require machinery to update components when document styles change, and I'm not sure if component vendors can guarantee or make the requirement that the important stylesheets in question load before the component code does.

As has been mentioned, providing events is an obvious way. Although another way could just be to allow providing a `StyleSheetList` object which `adoptedStyleSheets` would track:

```js
shadowRoot.adoptedStyleSheets = [
    // Not spreaded, automatically track all styleSheets even if it changes
    document.styleSheets,
];
```

> I don't think it's usually going a good idea to have an open-stylable shadow root nested in a parent _non_-open-stylable shadow root pull styles from outside that parent root

But that's exactly what many cases would boil down to, like if they're using some CSS libraries that can't be explictly imported into components for whatever reason then just capturing `document.styleSheets` is enough.

Like one of the motivations here is to allow incremental adoption of webcomponents, but because it's all-or-nothing they specifcally can't incremently take some styles but not others. If `open-styable` is shipped, you will inevitably start seeing *a lot* of questions like:

- "how do I make a stylesheet apply *only* to the document/shadowroot?"
    - when people inevitably start wanting some selectors to apply to the current component but not to accidentally leak into open-stylable shadow roots when people are accidentally leaking common class/ids downwards
- "how do I exclude some elements from open-styable?"
    - when people inevitably start wanting to have certain ids/classes that should only be styled from within the shadowroot but have been accidentally leaking from above

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/909#issuecomment-1251683421
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/909/1251683421@github.com>

Received on Monday, 19 September 2022 23:46:21 UTC