Re: [whatwg/dom] Should there be a declarative version of adoptedStyleSheets? (#910)

> why wouldn't a `<link rel="stylesheet" href="shared.css">` within a declared Shadow DOM implicitly be used/adopted as style for such Shadow DOM?

That (or an enclosed `<style>` tag) is the current recommended best practice for declarative Shadow DOM. In this case, the stylesheet wouldn't be used as an `adoptedStyleSheet`, but it would be added to `shadowRoot.styleSheets`. And further, most/all browsers optimize away repeated such `<link>` or `<style>` tags to point to a single, shared (copy on write) instance of a StyleSheet.

The downsides of this approach, which this issue tries to tackle, are:
 1. The overhead of sending repeated copies of `<style>` tags, or fetches for small `<link>` stylesheets.
 2. The fact that these shared stylesheets are only "copy on write" shared. Changing one of them does not change all of them, in contrast to `adoptedStyleSheets`.



-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/910#issuecomment-718159329

Received on Wednesday, 28 October 2020 19:29:44 UTC