Files
sousa-gecko/testing/web-platform/tests/custom-elements/registries/ShadowRoot-init-declarative.html
T
Blink WPT Bot df24a1dfbe Bug 2021721 [wpt PR 58342] - AttachShadow should use document's registry instead of tree scope's registry by default, a=testonly
Automatic update from web-platform-tests
AttachShadow should use document's registry instead of tree scope's registry by default (#58342)

* AttachShadow should use document's registry instead of tree scope's registry by default

As titled, according to spec, AttachShadow should use the document's
registry instead of tree scope's registry by default.

https://dom.spec.whatwg.org/#dom-element-attachshadow

Change-Id: I9dbe11a56448f9ccdd40dbf11eea28c648e51633
Bug: 486928691
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7600836
Commit-Queue: Jayson Chen <jaysonchen@microsoft.com>
Reviewed-by: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1595825}

* Address review: assert element registry unchanged after attachShadow

Assert that customElementRegistry of the element remains null after
calling attachShadow, verifying the shadow root's default registry
is independent of the element's registry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Jayson Chen <jaysonchen@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
--

wpt-commits: db31490389c9390aa3044cfff7a9cab677a870b8
wpt-pr: 58342
2026-05-08 08:38:32 +00:00

32 lines
1.3 KiB
HTML

<!doctype html>
<title>Scoped Custom Element Registries: declarative shadow root</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="host">
<template shadowrootmode="open" shadowrootcustomelementregistry>
<custom-element></custom-element>
<div></div>
</template>
</div>
<script>
test(() => {
const customElement = host.shadowRoot.firstElementChild;
assert_equals(customElement.customElementRegistry, null);
customElement.attachShadow({
mode: "open"
});
assert_equals(customElement.customElementRegistry, null);
assert_equals(customElement.shadowRoot.customElementRegistry, window.customElements);
}, "Custom element inside 'shadowrootcustomelementregistry' declarative shadow root should use document's registry as attachShadow default registry");
test(() => {
const divElement = host.shadowRoot.lastElementChild;
assert_equals(divElement.customElementRegistry, null);
divElement.attachShadow({
mode: "open"
});
assert_equals(divElement.customElementRegistry, null);
assert_equals(divElement.shadowRoot.customElementRegistry, window.customElements);
}, "Built-in element inside 'shadowrootcustomelementregistry' declarative shadow root should use document's registry as attachShadow default registry");
</script>