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
When a element with a shadowRoot that has adoptedStyleSheets is moved between documents, these styleSheets are removed per spec. This issue is also referenced here.
This is undesirable and requires significant fix-up code to prevent (~0.5KB, example) and is causing real developer pain points. If the element is a custom element, the logical place to fix the styling is adoptedCallback, but the adoptedStyleSheets have been removed by this point so a pre-processed cache of the of the adoptedStyleSheets must be maintained/managed. This is cumbersome, tricky to get right, and significant code to do correctly.
Note, using <style> elements in the shadowRoot does not trigger this issue.
I believe one concern that led to this restriction was breaking references to relative URLs in the stylesheet; however, baseUrl is now a constructor option. If this is the only reason they could not be shared, then if baseURL is specified, these sheets could be marked document shareable and not removed when the element is adopted to a new document.
This would make cross-document sharing of elements with shadowRoots significantly more feasible.
The text was updated successfully, but these errors were encountered:
When a element with a
shadowRoot
that hasadoptedStyleSheets
is moved between documents, these styleSheets are removed per spec. This issue is also referenced here.This is undesirable and requires significant fix-up code to prevent (~0.5KB, example) and is causing real developer pain points. If the element is a custom element, the logical place to fix the styling is
adoptedCallback
, but theadoptedStyleSheets
have been removed by this point so a pre-processed cache of the of the adoptedStyleSheets must be maintained/managed. This is cumbersome, tricky to get right, and significant code to do correctly.Note, using
<style>
elements in theshadowRoot
does not trigger this issue.I believe one concern that led to this restriction was breaking references to relative URLs in the stylesheet; however, baseUrl is now a constructor option. If this is the only reason they could not be shared, then if
baseURL
is specified, these sheets could be marked document shareable and not removed when the element is adopted to a new document.This would make cross-document sharing of elements with shadowRoots significantly more feasible.
The text was updated successfully, but these errors were encountered: