OLD | NEW |
(Empty) | |
| 1 <script> |
| 2 'use strict'; |
| 3 let constructors = []; |
| 4 test(() => { |
| 5 assert_equals(constructors.length, 0); |
| 6 |
| 7 class MyElement extends HTMLElement { |
| 8 constructor() { |
| 9 super(); |
| 10 constructors.push(this); |
| 11 } |
| 12 } |
| 13 |
| 14 customElements.define('my-element', MyElement); |
| 15 |
| 16 // createElement should synchronously call constructor. |
| 17 let el = document.createElement('my-element'); |
| 18 assert_equals(constructors.length, 1); |
| 19 |
| 20 let importDoc = document.currentScript.ownerDocument; |
| 21 let sandbox = importDoc.querySelector('#sandbox'); |
| 22 |
| 23 // createElement should work in imported document. |
| 24 let el2 = importDoc.createElement('my-element') |
| 25 assert_equals(constructors.length, 2); |
| 26 |
| 27 // new MyElement() should synchronously call constructor. |
| 28 let el3 = new MyElement(); |
| 29 assert_equals(constructors.length, 3); |
| 30 |
| 31 assert_array_equals(constructors, [el, el2, el3]); |
| 32 }, 'createElement() should work in imported document.'); |
| 33 </script> |
OLD | NEW |