Bug 299300
| Summary: | Calling attachShadow does not inherit host customElementRegistry as expected | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Steve Orvell <steveorvell> |
| Component: | DOM | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED INVALID | ||
| Severity: | Normal | CC: | annevk, justin, rniwa |
| Priority: | P2 | ||
| Version: | Safari 26 | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Steve Orvell
When `attachShadow` is called without a registry, the shadowRoot does not inherit the host's customElementRegistry.
See reproduction: https://codepen.io/Steve-Orvell/pen/xbZGxOW?editors=1000
This expectation is based on https://dom.spec.whatwg.org/#dom-element-attachshadow
"The attachShadow(init) method steps are:
Let registry be this’s custom element registry."
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Justin Fagnani
The spec behavior seems wrong. If the custom element isn't passing a registry to attachShadow(), then presumably it's expecting use the global registry. Using its parent scope's registry would very easily break it as that scope might be missing custom element definitions from self-registering element dependencies.
Ryosuke Niwa
attachShadow isn't supposed to inherit host's customElementRegistry.
Steve Orvell
@Ryosuke
1. Can you explain the linked spec text?
2. Can you explain the inconsistency between a shadowRoot on a div and on an undefined custom element candidate in the linked repro?
Anne van Kesteren
1. See https://github.com/whatwg/dom/issues/1407.
2. The patch for bug 300027 did capture the test for the div element inside an "inert" shadow root itself getting a shadow root with a custom element registry. No fix for that yet though, but it seems wrong to track it as part of this bug which started out about something else.