You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A CSSStyleSheet can only be applied to the Document it is constructed on (e.g. the document on which the factory function is called on), and any ShadowRoot in the Document it is constructed on, by assigning an array containing the sheet to their adoptedStyleSheets. So, a stylesheet can be used in multiple DocumentOrShadowRoots within the document it is constructed on.
Non-explicitly constructed stylesheets cannot be added to adoptedStyleSheets.
There are a few problems here:
The definition of which document a sheet is associated with is not clear. Is it the this object of the factory method, or a document derived from the factory method itself (from its Realm)? Those can be different if .call is used. Presumably it should just be the this object of the factory method. Ideally this would be clearly specified in the factory methods by storing a reference to the "context object" Document on the resulting sheet. This may require adding a state item ("pinned document", "unique document", "document", there are several options for naming and semantics here) to https://drafts.csswg.org/cssom/#css-style-sheets but that shouldn't be too bad, especially since CSSOM has a reasonably active editor now.
There is currently no state associated with a stylesheet that indicates whether it's an "explicitly constructed stylesheet". Presumably @imports from constructed stylesheets are "non-explicitly constructed stylesheets", but right not that's not really defined. The Document state from item 1 might work to identify "constructed stylesheets", depending on how it's defined.
The spec doesn't define what happens if you do try to assign a sheet in the wrong document. Presumably the adoptedStyleSheets setter should throw in this case. This might be best addressed by writing down actual steps for that setter. Those steps would also do the throwing for non-explicitly constructed stylesheets. You will need some handwaving in terms of how you're getting your hands on the actual stylesheets from the FrozenArray because that's slightly rocket-science at the moment; please talk to @domenic about that.
The text was updated successfully, but these errors were encountered:
https://wicg.github.io/construct-stylesheets/index.html#using-constructed-stylesheets says:
There are a few problems here:
The definition of which document a sheet is associated with is not clear. Is it the
this
object of the factory method, or a document derived from the factory method itself (from its Realm)? Those can be different if.call
is used. Presumably it should just be thethis
object of the factory method. Ideally this would be clearly specified in the factory methods by storing a reference to the "context object"Document
on the resulting sheet. This may require adding a state item ("pinned document", "unique document", "document", there are several options for naming and semantics here) to https://drafts.csswg.org/cssom/#css-style-sheets but that shouldn't be too bad, especially since CSSOM has a reasonably active editor now.There is currently no state associated with a stylesheet that indicates whether it's an "explicitly constructed stylesheet". Presumably
@imports
from constructed stylesheets are "non-explicitly constructed stylesheets", but right not that's not really defined. TheDocument
state from item 1 might work to identify "constructed stylesheets", depending on how it's defined.The spec doesn't define what happens if you do try to assign a sheet in the wrong document. Presumably the
adoptedStyleSheets
setter should throw in this case. This might be best addressed by writing down actual steps for that setter. Those steps would also do the throwing for non-explicitly constructed stylesheets. You will need some handwaving in terms of how you're getting your hands on the actual stylesheets from theFrozenArray
because that's slightly rocket-science at the moment; please talk to @domenic about that.The text was updated successfully, but these errors were encountered: