Skip to content

Avoid leaking documents in CustomElementRegistry's scoped document set #12092

@Jamesernator

Description

@Jamesernator

What is the issue with the HTML Standard?

As spec-ed the scoped document set holds a strong list of documents in the custom element registry. As far as I can tell, documents are never removed from this set so holding onto a CustomElementRegistry would leak documents (even if they had no relevant children to upgrade!).

e.g. In the following example, the created document leaks as long as registry lives:

const registry = new CustomElementRegistry();
const document = Document.parseHTMLUnsafe(`<!doctype html><x-foo></x-foo>`);

registry.initialize(document.querySelector("x-foo"));

Given the only usage of the "scoped document set" is to upgrade relevant elements in a document whose custom element registry is already the registry we're calling .define on, can't we just hold a weak set of elements which need upgrading? (And simply build the set of documents during upgrade?).

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: custom elementsRelates to custom elements (as defined in DOM and HTML)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions