OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <script src="../../resources/testharness.js"></script> | |
3 <script src="../../resources/testharnessreport.js"></script> | |
4 <script> | |
5 'use strict'; | |
kochi
2016/08/22 07:37:35
Conversion to async-style is not yet done for this
| |
6 setup({ explicit_done: true }); | |
7 let reactions = []; | |
8 customElements.define('x-x', class extends HTMLElement { | |
9 constructor() { | |
10 super(); | |
11 reactions.push({ type: 'constructor', element: this }); | |
12 } | |
13 }); | |
14 test(() => { | |
15 assert_equals(reactions.length, 0); | |
16 }, 'Should not have parsed <x-x> yet'); | |
17 </script> | |
18 | |
19 <x-x></x-x> | |
20 | |
21 <script> | |
22 'use strict'; | |
23 test(() => { | |
24 assert_equals(reactions.length, 1); | |
25 }, 'Parser should invoke the custom element constructor'); | |
26 | |
27 let import1 = document.createElement('link'); | |
28 import1.rel = 'import'; | |
29 import1.href = 'resources/import-custom.html'; | |
30 document.head.appendChild(import1); | |
31 | |
32 import1.onload = () => { | |
33 test(() => { | |
34 assert_equals(reactions.length, 2); | |
35 }, 'import should invoke the custom element constructor'); | |
36 | |
37 let elementsInMaster = document.getElementsByTagName('x-x'); | |
38 let elementsInImport = import1.import.getElementsByTagName('x-x'); | |
39 test(() => { | |
40 assert_equals(reactions[0].element, elementsInMaster[0]); | |
41 assert_equals(reactions[1].element, elementsInImport[0]); | |
42 }, 'Constructor should run in the order elements are created'); | |
43 | |
44 done(); | |
45 }; | |
46 </script> | |
OLD | NEW |