Skip to content

Spec should define which global object to use for promises #128

@nordzilla

Description

@nordzilla

Consider when CSSStyleSheet.replace() needs to create a promise to either resolve or reject. In most cases, we can create a promise with the global object that we retrieve from the sheet's associated document. For constructed style sheets, the associated document would be the sheet's constructor document.

There are some edge cases, however, where the sheet may not have an associated document from which to retrieve a global object:

let style = document.createElement("style");
document.head.appendChild(style);
let sheet = style.sheet;
style.remove(); // sheet's associated document becomes null.
sheet.replace(''); 

Ideally, this code should still return a rejected promise with a NotAllowedError since this is not a constructed sheet. But it should be well-defined in the spec which global object should be used to create the promise in the event that there is no associated document.

It appears that Blink uses the caller's global object in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions