OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <template> | 2 <template> |
3 <style> | 3 <style> |
4 @import url(hello.css); | 4 @import url(hello.css); |
5 </style> | 5 </style> |
6 <h1>Hello</h1> | 6 <h1>Hello</h1> |
7 </template> | 7 </template> |
8 <script> | 8 <script> |
9 var t = document.currentScript.ownerDocument.querySelector('template'); | 9 var t = document.currentScript.ownerDocument.querySelector('template'); |
10 var proto = Object.create(HTMLElement.prototype); | 10 var proto = Object.create(HTMLElement.prototype); |
11 proto.createdCallback = function() { | 11 proto.createdCallback = function() { |
12 var root = this.createShadowRoot(); | 12 var root = this.createShadowRoot(); |
13 root.appendChild(document.importNode(t.content)); | 13 root.appendChild(document.importNode(t.content, true)); |
14 }; | 14 }; |
15 document.registerElement('x-test', {prototype: proto}); | 15 document.registerElement('x-test', {prototype: proto}); |
16 </script> | 16 </script> |
OLD | NEW |