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
How can one detect when the sheet is "done loading"? #9
One idea would be making CSSStyleSheet an EventTarget, so that load event can be dispatched when all the dependencies are complete. The other idea would be adding a method that returns a promise which resolves at everything is ready.
One of the motivation for having this (for custom elements default style or any shadow roots) is not only for memory saving to share the multiple instance of the same stylesheet among all the shadow trees, but also avoid firing "load" event for every <style> element in each shadow tree instance.
In that context, firing only one "load" event for an constructed instance (not when added to shadow tree) sounds good.
Activity
TakayoshiKochi commentedon Apr 6, 2018
One idea would be making
CSSStyleSheetanEventTarget, so thatloadevent can be dispatched when all the dependencies are complete. The other idea would be adding a method that returns a promise which resolves at everything is ready.calebdwilliams commentedon Apr 6, 2018
Is there an equivalent for a typical
HTMLStyleElement? If there is, I would think matching that as closely as possible would be ideal.bzbarsky commentedon Apr 6, 2018
HTMLStyleElementis anEventTargetand fires load/error events (though in some browsers those are pretty buggy).TakayoshiKochi commentedon Apr 9, 2018
One of the motivation for having this (for custom elements default style or any shadow roots) is not only for memory saving to share the multiple instance of the same stylesheet among all the shadow trees, but also avoid firing "load" event for every <style> element in each shadow tree instance.
In that context, firing only one "load" event for an constructed instance (not when added to shadow tree) sounds good.
TakayoshiKochi commentedon May 22, 2018
As #25 concludes disallowing
@import, it makes little sense to dispatch aloadevent on the constructed stylesheet, which should be ready.Let's revisit this once #2 (asynchronous parsing) or URL-based construction is considered.
tabatkins commentedon May 22, 2018
Reopening because #25 is not actually resolved.
rakina commentedon Aug 28, 2018
From #11 (comment), we don't want to expose the CSSStyleSheet when it's not done loading, so we know it's done loading when the promise is resolved.
rakina commentedon Aug 30, 2018
Closed with #33 (with what I said in the previous comment)