Skip to content

How can one detect when the sheet is "done loading"? #9

Closed

Description

@bzbarsky

If the sheet has @import rules, how can the API consumer tell when the sheet is done loading all the imports and is ready to be used?

Activity

  1. TakayoshiKochi commented on Apr 6, 2018

    @TakayoshiKochi
    Member

    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.

  2. calebdwilliams commented on Apr 6, 2018

    @calebdwilliams

    Is there an equivalent for a typical HTMLStyleElement? If there is, I would think matching that as closely as possible would be ideal.

  3. bzbarsky commented on Apr 6, 2018

    @bzbarsky
    Author

    HTMLStyleElement is an EventTarget and fires load/error events (though in some browsers those are pretty buggy).

  4. TakayoshiKochi commented on Apr 9, 2018

    @TakayoshiKochi
    Member

    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.

  5. added
    needs resolution
    on Apr 17, 2018
  6. TakayoshiKochi commented on May 22, 2018

    @TakayoshiKochi
    Member

    As #25 concludes disallowing @import, it makes little sense to dispatch a load event on the constructed stylesheet, which should be ready.

    Let's revisit this once #2 (asynchronous parsing) or URL-based construction is considered.

  7. tabatkins commented on May 22, 2018

    @tabatkins
    Contributor

    Reopening because #25 is not actually resolved.

  8. rakina commented on Aug 28, 2018

    @rakina
    Member

    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.

  9. rakina commented on Aug 30, 2018

    @rakina
    Member

    Closed with #33 (with what I said in the previous comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs resolution

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions