Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
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();
Expand Down Expand Up @@ -49,7 +49,7 @@
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();
Expand Down Expand Up @@ -78,13 +78,33 @@
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>