- From: Mayank <notifications@github.com>
- Date: Mon, 30 Sep 2024 12:21:08 -0700
- To: WICG/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 30 September 2024 19:21:12 UTC
Would it make sense to observe a `StyleSheetList` instead of a node (`Document` or `ShadowRoot`)? ```js const observer = new StyleSheetObserver(); observer.observe(document.styleSheets); observer.observe(document.adoptedStyleSheets); observer.observe(shadowRoot.adoptedStyleSheets); ``` --- A related point that I [mentioned](https://github.com/w3c/csswg-drafts/issues/10013#issuecomment-2002269431) in https://github.com/w3c/csswg-drafts/issues/10013, but is also worth repeating here. One of the main use-cases for observing stylesheets is to keep stylesheets synced between `document` and a `shadowRoot`. From an author perspective, it would nice if we could just do this: ```js shadowRoot.adoptedStyleSheets.push(document.styleSheets); ``` Since `document.styleSheets` is a stable `StyleSheetList` reference, the browser could internally observe changes to it and automatically keep it in sync, without requiring authors to wire up the logic manually. For other, more advanced cases, `StyleSheetObserver` could still be useful. -- Reply to this email directly or view it on GitHub: https://github.com/WICG/webcomponents/issues/1041#issuecomment-2383978380 You are receiving this because you are subscribed to this thread. Message ID: <WICG/webcomponents/issues/1041/2383978380@github.com>
Received on Monday, 30 September 2024 19:21:12 UTC