Re: [w3ctag/design-reviews] Declarative CSS Modules and Declarative Shadow DOM `adoptedstylesheets` attribute (Issue #1000)

sorvell left a comment (w3ctag/design-reviews#1000)

> what goes wrong if... those styles don't wind up in the adoptedStyleSheets array?

Typically, DSD is used to mirror and fully emulate (often via server rendering + hydration) an element that can otherwise be imperatively rendered. If `adoptedStyleSheets` isn't used, presumably an element(s) in the shadowRoot would be? If so, this is semantically different from the imperative version that would almost certainly use `adoptedStyleSheets`. That difference can lead to subtle issues in both performance and correctness. A style/link element is heavier weight than a stylesheet, and the presence of an unexpected element can influence the styling of other elements in the tree. In the case of a link element it would have to **_100% guarantee not to produce a FOUC_**. Unfortunately, documentation and spec behavior for FOUC is extremely confusing.

> Are folks modifying these sheets, and expecting those modifications to change everywhere that refers to them?

In some advanced cases, yes. And again, if the platform provides some *alternate* mechanism for DSD, these use cases just become incompatible. 

> Are folks reading sheets out of adoptedStyleSheets and expecting that to be complete?

Yes. The styling API for Shadow DOM has [not evolved](https://github.com/WICG/webcomponents/issues/909) to meet user needs, and this leads to use cases that involve relying on and manipulating `adoptedStyleSheets`.

In short, `adoptedStyleSheets` is by far the most common way to apply styles to Shadow DOM. I really haven't seen anyone use or prefer style/link since the addition of `adoptedStyleSheets` except since the introduction of DSD. And that's led directly to this issue...

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/1000#issuecomment-3130079651
You are receiving this because you are subscribed to this thread.

Message ID: <w3ctag/design-reviews/issues/1000/3130079651@github.com>

Received on Monday, 28 July 2025 22:57:54 UTC