Skip to content

Commit 0ab0302

Browse files
annevkmoz-wptsync-bot
authored andcommitted
Bug 2001295 [wpt PR 56132] - CustomElementRegistry.prototype.initialize upgrades already initialized elements, a=testonly
Automatic update from web-platform-tests CustomElementRegistry.prototype.initialize upgrades already initialized elements For whatwg/html#11913. -- wpt-commits: ba9d85e81e45978e36b8d4b26b7a91e65383b296 wpt-pr: 56132
1 parent a66869f commit 0ab0302

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

testing/web-platform/tests/custom-elements/registries/scoped-registry-initialize-upgrades.html

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
assert_equals(element.customElementRegistry, null);
1919
registry.initialize(element);
2020
assert_equals(element.customElementRegistry, registry);
21-
}, `${title}: customElementRegistry.prototype.initialize should upgrade the element given to the first argument`);
21+
}, `${title}: CustomElementRegistry.prototype.initialize should upgrade the element given to the first argument`);
2222

2323
test(() => {
2424
const doc = makeDocument();
@@ -49,7 +49,7 @@
4949
assert_equals(registryInConstructor.length, 2);
5050
assert_equals(registryInConstructor[0], registry);
5151
assert_equals(registryInConstructor[1], registry);
52-
}, `${title}: customElementRegistry.prototype.initialize should upgrade elements in tree order`);
52+
}, `${title}: CustomElementRegistry.prototype.initialize should upgrade elements in tree order`);
5353

5454
test(() => {
5555
const doc1 = makeDocument();
@@ -78,13 +78,33 @@
7878
assert_true(undefinedElement1 instanceof ABElement);
7979
assert_equals(undefinedElement2.customElementRegistry, registry2);
8080
assert_equals(undefinedElement2.__proto__.constructor.name, 'HTMLElement');
81-
}, `${title}: customElementRegistry.prototype.initialize only upgrades elements beloning to the registry`);
81+
}, `${title}: CustomElementRegistry.prototype.initialize only upgrades elements beloning to the registry`);
8282
}
8383

8484
runTest('Document', () => new Document);
8585
runTest('HTMLDocument', () => document.implementation.createHTMLDocument());
8686
runTest('XHTMLDocument', () => document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null));
8787

88+
test(() => {
89+
class ABElement extends HTMLElement { };
90+
const registry = new CustomElementRegistry;
91+
92+
const element = document.createElement('a-b', { customElementRegistry: registry });
93+
assert_equals(element.customElementRegistry, registry);
94+
assert_equals(element.__proto__.constructor.name, 'HTMLElement');
95+
assert_false(element instanceof ABElement);
96+
97+
registry.define('a-b', ABElement);
98+
assert_equals(element.customElementRegistry, registry);
99+
assert_equals(element.__proto__.constructor.name, 'HTMLElement');
100+
assert_false(element instanceof ABElement);
101+
102+
registry.initialize(element);
103+
assert_equals(element.customElementRegistry, registry);
104+
assert_equals(element.__proto__.constructor.name, 'ABElement');
105+
assert_true(element instanceof ABElement);
106+
}, `CustomElementRegistry.prototype.initialize upgrades already initialized elements`);
107+
88108
</script>
89109
</body>
90110
</html>

0 commit comments

Comments
 (0)