blob: 23a050f37e748583bb3090d9cb0b22f90d4abd51 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting script and custom element from a DocumentFragment</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<body>
<script>
let customConstructed = false;
let customConstructedDuringEarlierScript = false;
class CustomElement extends HTMLElement {
constructor() {
super();
customConstructed = true;
}
}
test(() => {
const script = document.createElement("script");
script.textContent = `
customElements.define("custom-element", CustomElement);
customConstructedDuringEarlierScript = customConstructed;
`;
const custom = document.createElement("custom-element");
const df = document.createDocumentFragment();
df.appendChild(script);
df.appendChild(custom);
assert_false(customConstructed);
assert_false(customConstructedDuringEarlierScript);
document.head.appendChild(df);
assert_true(customConstructed);
assert_true(customConstructedDuringEarlierScript);
}, "An earlier-inserted script can upgrade a later-inserted custom element, " +
"whose upgrading is synchronously observable to the script, since DOM " +
"insertion has been completed by the time it runs");
</script>
|