Skip to content

attachShadow default custom element registry #1407

@ja-y-son

Description

@ja-y-son

What is the issue with the DOM Standard?

When calling attachShadow without specified custom element registry, is the new shadow root supposed to inherit host's custom element registry or use the global registry?

From the first step in DOM spec:
"Let registry be this’s custom element registry."
It sounds like we are expecting the shadow root to inherit the host's custom element registry.

However, from this webkit issue, it sounds like this should not be the expected behavior and global registry should be used by default.

Looking at the current implementation in webkit (20623.1.7.19.1), the behavior aligns with the spec and inherits the host's custom element registry instead of the global one.

const scopedRegistry = new CustomElementRegistry();
const scopedElement = document.createElement('div', {customElementRegistry: scopedRegistry});
const shadowRoot = element.attachShadow({mode: 'closed'});
shadowRoot.customElementRegistry === scopedRegistry     // true
shadowRoot.customElementRegistry === customElements   // false

Would like to clarify the spec and the expected behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions