Skip to content

Commit 1b9a886

Browse files
ja-y-sonJayson Chen
andauthored
Add test to verify "keep custom element registry null" behavior for shadowroot (#56237)
Co-authored-by: Jayson Chen <jaysonchen@microsoft.com>
1 parent 09b9ffe commit 1b9a886

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

custom-elements/registries/element-mutation.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@
2020
</div>
2121
</div>
2222

23+
<template id="template">
24+
<div id="template-host-1">
25+
<template shadowrootmode="open" shadowrootclonable><x-foo></x-foo></template>
26+
</div>
27+
<div id="template-host-2">
28+
<template shadowrootmode="open" shadowrootclonable shadowrootcustomelementregistry><x-foo></x-foo></template>
29+
</div>
30+
</template>
31+
2332
<script>
2433

2534
test(() => {
@@ -66,5 +75,13 @@
6675
assert_equals(element.customElementRegistry, registry1);
6776
}, "An element with scoped registry should not change its registry when moved into another shadow tree with different scoped registry.")
6877

78+
test(() => {
79+
customElements.define('x-foo', class extends HTMLElement {});
80+
const template = document.getElementById('template');
81+
document.body.append(template.content.cloneNode(true));
82+
assert_equals(document.querySelector('#template-host-1').shadowRoot.querySelector('x-foo').customElementRegistry, customElements);
83+
assert_equals(document.querySelector('#template-host-2').shadowRoot.querySelector('x-foo').customElementRegistry, null);
84+
}, "Declarative shadow DOM with shadowrootcustomelementregistry attribute without registry initialized should remain null registry after adoption.")
85+
6986
</script>
7087
</body>

0 commit comments

Comments
 (0)