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

> The problem with such a design is that it's all-or-nothing, like it provides exactly one style inheritance strategy.

It provides another feature on top of other style sharing that we already have: CSS property inheritance, and shared stylesheet references, and in addition to hopefully future style-sharing systems like ::theme() or something similar. Using open-stylable shadow roots would not preclude use these other features.

> Like even if people want inheritance from the document (which is certainly very common), I doubt people in general want to inherit styles from every shadow root in between, ESPECIALLY with id selectors.

The point of inheriting from the scope above is that it's composable and doesn't break other element's encapsulation. Just like how CSS shadow parts don't automatically re-export, 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.

> A solution like `shadowRoot.adoptedStyleSheets = [...document.styleSheets]`

The main problem I see with this is that it's imperative and one-time. 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.

I _do_ think that being able to adopt other stylesheets (without having to re-parse the text content) would be very useful in general (especially in SSR), so I would be very supportive of making `shadowRoot.adoptedStyleSheets.push(...document.styleSheets)` possible at least.


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

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

Received on Monday, 19 September 2022 19:16:00 UTC