commit e5bf0caff1f5b40233c9cc2ef639d1aeeba1bc30
parent d536f79becb324244987cd75bcf3a457832df187
Author: Anne van Kesteren <annevk@annevk.nl>
Date: Sat, 22 Nov 2025 21:11:31 +0000
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 https://github.com/whatwg/html/pull/11913.
--
wpt-commits: ba9d85e81e45978e36b8d4b26b7a91e65383b296
wpt-pr: 56132
Diffstat:
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/testing/web-platform/tests/custom-elements/registries/scoped-registry-initialize-upgrades.html b/testing/web-platform/tests/custom-elements/registries/scoped-registry-initialize-upgrades.html
@@ -18,7 +18,7 @@ function runTest(title, makeDocument, makeCustomElementRegistry) {
assert_equals(element.customElementRegistry, null);
registry.initialize(element);
assert_equals(element.customElementRegistry, registry);
- }, `${title}: customElementRegistry.prototype.initialize should upgrade the element given to the first argument`);
+ }, `${title}: CustomElementRegistry.prototype.initialize should upgrade the element given to the first argument`);
test(() => {
const doc = makeDocument();
@@ -49,7 +49,7 @@ function runTest(title, makeDocument, makeCustomElementRegistry) {
assert_equals(registryInConstructor.length, 2);
assert_equals(registryInConstructor[0], registry);
assert_equals(registryInConstructor[1], registry);
- }, `${title}: customElementRegistry.prototype.initialize should upgrade elements in tree order`);
+ }, `${title}: CustomElementRegistry.prototype.initialize should upgrade elements in tree order`);
test(() => {
const doc1 = makeDocument();
@@ -78,13 +78,33 @@ function runTest(title, makeDocument, makeCustomElementRegistry) {
assert_true(undefinedElement1 instanceof ABElement);
assert_equals(undefinedElement2.customElementRegistry, registry2);
assert_equals(undefinedElement2.__proto__.constructor.name, 'HTMLElement');
- }, `${title}: customElementRegistry.prototype.initialize only upgrades elements beloning to the registry`);
+ }, `${title}: CustomElementRegistry.prototype.initialize only upgrades elements beloning to the registry`);
}
runTest('Document', () => new Document);
runTest('HTMLDocument', () => document.implementation.createHTMLDocument());
runTest('XHTMLDocument', () => document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null));
+test(() => {
+ class ABElement extends HTMLElement { };
+ const registry = new CustomElementRegistry;
+
+ const element = document.createElement('a-b', { customElementRegistry: registry });
+ assert_equals(element.customElementRegistry, registry);
+ assert_equals(element.__proto__.constructor.name, 'HTMLElement');
+ assert_false(element instanceof ABElement);
+
+ registry.define('a-b', ABElement);
+ assert_equals(element.customElementRegistry, registry);
+ assert_equals(element.__proto__.constructor.name, 'HTMLElement');
+ assert_false(element instanceof ABElement);
+
+ registry.initialize(element);
+ assert_equals(element.customElementRegistry, registry);
+ assert_equals(element.__proto__.constructor.name, 'ABElement');
+ assert_true(element instanceof ABElement);
+}, `CustomElementRegistry.prototype.initialize upgrades already initialized elements`);
+
</script>
</body>
</html>