[csswg-drafts] [css-om] Can we lift the restriction on constructed flag for adoptedStylesheets? (#10013)

keithamus has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-om] Can we lift the restriction on constructed flag for adoptedStylesheets? ==
Currently `adoptedStyleSheets` has a restriction on `CSSStyleSheets` that have the `constructed` flag set:

> The [set an indexed value](https://webidl.spec.whatwg.org/#observable-array-attribute-set-an-indexed-value) algorithm for adoptedStyleSheets, given value and index, is the following:
>
> 1. If value’s [constructed flag](https://drafts.csswg.org/cssom/#concept-css-style-sheet-constructed-flag) is not set, or its [constructor document](https://drafts.csswg.org/cssom/#concept-css-style-sheet-constructor-document) is not equal to this [DocumentOrShadowRoot](https://dom.spec.whatwg.org/#documentorshadowroot)'s [node document](https://dom.spec.whatwg.org/#concept-node-document), throw a "[NotAllowedError](https://webidl.spec.whatwg.org/#notallowederror)" [DOMException](https://webidl.spec.whatwg.org/#idl-DOMException).

I'm here to rattle this Chesterton's fence. It would be _really_ useful to be able to pluck a documents stylesheets and adopt it into a shadowroots `adoptedStyleSheets`, co-opting the pages styles while applying the shadow's own styles. Currently this is possible with a rather unfortunate amount of JS by duplicating a `<link>` tag and stuffing it in your shadow-dom, but it feels like we can make this easier?

(Cue discussion about `@import` and media queries...)

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10013 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 28 February 2024 19:21:53 UTC