Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need some wordsmithing on the "using constructed stylesheets" section #52

Closed
bzbarsky opened this issue Oct 23, 2018 · 5 comments
Closed

Comments

@bzbarsky
Copy link

bzbarsky commented Oct 23, 2018

https://wicg.github.io/construct-stylesheets/index.html#using-constructed-stylesheets says:

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:

  1. 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.

  2. 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.

  3. 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.

@bzbarsky
Copy link
Author

Just found #41 of which my item 3 above is a duplicate, I think.

@bzbarsky
Copy link
Author

And I guess #50 (which I think got filed while I was typing the above) is pretty similar...

@bzbarsky
Copy link
Author

Is there a CSSOM issue tracking adding the "associated document" bit?

@domenic
Copy link
Contributor

domenic commented Oct 26, 2018

We should probably wait to resolve #58/#23/etc. first?

@bzbarsky
Copy link
Author

Ah, true. OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants