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
{{ message }}
Repository navigation
Can the same constructed stylesheet be used in two different Documents? #23
This question is about different window.document instances, e.g. from different origins. The same constructed stylesheet can certainly be used in many shadow roots under the same document - that is the primary use case.
I would be weary of that possibility because I can see foresee instances where library authors might want to check if the object they get is an instance of CSSStyleSheet. If the constructors aren’t the same, that might cause an issue (unless I’m missing the point).
I think if once a constructed stylesheet is associated with any browsing context (i.e. specified for
actual rendering), then reusing that same object to another browsing context would throw an exception
(e.g. at the point that the object is added to .moreStyles or whatever it ends up with).
Reopening after @annevk's comment on WICG/webcomponents#759 (comment). Maybe it's OK to make a stylesheet be usable in more than one Documents if we clearly define things that need to be defined?
According to #10, the URL of the stylesheet will stay the same, that is the document it is constructed on. For fetch group, we might want to use the one for the document it's constructed on? Not sure, I'll try to find out...
One of the other things that was pointed out was the security aspect - can we modify another Document's <style> element's stylesheet? If we can't, then maybe it make sense to not allow injecting a constructed stylesheet to another Document.
cc @tabatkins, who might be able to help solve these questions
Activity
calebdwilliams commentedon Mar 2, 2018
For the purposes of this question does "documents" include document fragments (so shadow roots) or just a
window.document?ewilligers commentedon Mar 3, 2018
This question is about different
window.documentinstances, e.g. from different origins. The same constructed stylesheet can certainly be used in many shadow roots under the same document - that is the primary use case.calebdwilliams commentedon Mar 4, 2018
I would be weary of that possibility because I can see foresee instances where library authors might want to check if the object they get is an instance of
CSSStyleSheet. If the constructors aren’t the same, that might cause an issue (unless I’m missing the point).TakayoshiKochi commentedon Apr 6, 2018
I think if once a constructed stylesheet is associated with any browsing context (i.e. specified for
actual rendering), then reusing that same object to another browsing context would throw an exception
(e.g. at the point that the object is added to
.moreStylesor whatever it ends up with).TakayoshiKochi commentedon May 22, 2018
Let's conclude that a constructed stylesheet can only be associated with one document.
I'll close this once corresponding spec draft change is done.
Implement Document.createEmptyCSSStyleSheet
Delete constructor for creating empty CSSStyleSheets
Revert "Delete constructor for creating empty CSSStyleSheets"
rakina commentedon Sep 12, 2018
#35 resolves this. It can't be used in multiple
Documents.Restrict the use of CSSStyleSheets to only one Document
rakina commentedon Sep 28, 2018
Reopening after @annevk's comment on WICG/webcomponents#759 (comment). Maybe it's OK to make a stylesheet be usable in more than one Documents if we clearly define things that need to be defined?
According to #10, the URL of the stylesheet will stay the same, that is the document it is constructed on. For fetch group, we might want to use the one for the document it's constructed on? Not sure, I'll try to find out...
One of the other things that was pointed out was the security aspect - can we modify another Document's <style> element's stylesheet? If we can't, then maybe it make sense to not allow injecting a constructed stylesheet to another Document.
cc @tabatkins, who might be able to help solve these questions
rakina commentedon Dec 10, 2018
Resolved with #61.
25 remaining items
Remove adopted stylesheets when adopting to a different document
Bug 1523562 [wpt PR 14921] - Remove adopted stylesheets when adopting…
Bug 1523562 [wpt PR 14921] - Remove adopted stylesheets when adopting…
Bug 1523562 [wpt PR 14921] - Remove adopted stylesheets when adopting…
Bug 1523562 [wpt PR 14921] - Remove adopted stylesheets when adopting…
Bug 1523562 [wpt PR 14921] - Remove adopted stylesheets when adopting…
Bug 1523562 [wpt PR 14921] - Remove adopted stylesheets when adopting…
Bug 1523562 [wpt PR 14921] - Remove adopted stylesheets when adopting…
Bug 1523562 [wpt PR 14921] - Remove adopted stylesheets when adopting…
Bug 1523562 [wpt PR 14921] - Remove adopted stylesheets when adopting…
Bug 1523562 [wpt PR 14921] - Remove adopted stylesheets when adopting…
heycam commentedon Jan 17, 2020
@rakina can this issue be closed? I think your spec changes to follow the #23 (comment) proposal were made.
rakina commentedon Jan 20, 2020
Oops yeah forgot to actually close the issue. Thanks!
Bug 1523562 [wpt PR 14921] - Remove adopted stylesheets when adopting…