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

> I would like to propose that there be an option to let styles from the scope above a shadow root apply to the shadow root. There would be nothing special about document styles. If developers want styles to apply more deeply down the tree of shadow roots, then every intermedia shadow root would have to be open stylable as well.

The problem with such a design is that it's all-or-nothing, like it provides exactly one 
style inheritance strategy. 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 inbetween, ESPECIALLY with id selectors.

A solution like `shadowRoot.adoptedStyleSheets = [...document.styleSheets]` is nice because it allows people to decide if they just need `document` sheets or need sheets from all intermediate shadow roots. And with filtering people can be more picky, like they might tag sheets with a title to indicate those that should or shouldn't be inherited e.g.:

```html
<link rel="stylesheet" title="inherit">
```

```js
shadowRoot.styleSheets = [
    ...document.styleSheets,
    ...shadowRoot.host.getRootNode().styleSheets,
].filter(sheet => sheet.title === "inherit");
```

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

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

Received on Monday, 19 September 2022 01:50:51 UTC