Skip to content

Should adopting from a Document into its associated inert template document (and vice versa) clear the adoptedStyleSheets? #133

@rakina

Description

@rakina

This came up on a recent Chromium bug. Currently adopting a shadow root with non-empty adoptedStyleSheets into a <template> document will clear the adoptedStyleSheets, and vice versa.

Say we have a Document X and it has a <template> element in it. The <template>'s contents' node document is the Document's associated-inert-template-document. This is a different Document than X, and adopting into or out of the <template>'s contents will clear the adoptedStyleSheets per our spec).

Maybe it's ok if we treat a Document and its associated-inert-template-document as the same document for adoptedStyleSheets related purposes, by adding a special case to the "adopting steps" to not clear adoptedStyleSheets if:

And I think the constructor document will never be an associated-inert-template-document itself because that document is inert and shouldn't be able to construct stylesheets via script, but I might be wrong.

The main reasons we disallowed reusing constructed stylesheets on different documents are the concern that a constructed stylesheet from a document might keep the document alive, and different documents might have different fetch groups. I think this should be ok with the new addition. The <template>'s contents lifetime should be bounded by the document it is in, unless it gets adopted to a different document, in which case the adoptedStyleSheets will be cleared.

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