blob: 58d376115b1fdd272668147003c09f6de544a04f [file] [log] [blame]
<!DOCTYPE html>
<title>Custom Elements: Remove an element</title>
<link rel="help" href="https://dom.spec.whatwg.org/#concept-node-remove">
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/custom-elements-helpers.js"></script>
<body>
<script>
'use strict';
// 15. For each shadow-including descendant descendant of node, in shadow-including tree order,
// run these substeps:
// 2. If descendant is custom, then enqueue a custom element callback reaction with descendant,
// callback name "disconnectedCallback", and an empty argument list.
test_with_window((w) => {
w.document.body.innerHTML = `
<a-a id="a">
<p>
<a-a id="b"></a-a>
<a-a id="c"></a-a>
</p>
<a-a id="d"></a-a>
</a-a>`;
let invocations = [];
class X extends w.HTMLElement {
disconnectedCallback() { invocations.push(this); }
}
w.customElements.define('a-a', X);
w.document.getElementById("a").remove();
assert_array_equals(['a', 'b', 'c', 'd'], invocations.map((e) => e.id),
'four elements should have been removed in doc order');
},'Remove an element');
</script>
</body>