OLD | NEW |
1 <!-- | 1 <!-- |
2 // Copyright 2015 The Chromium Authors. All rights reserved. | 2 // Copyright 2015 The Chromium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 --> | 5 --> |
6 <script> | 6 <script> |
7 import "dart:mirrors"; | 7 import "dart:mirrors"; |
8 import "dart:sky"; | 8 import "dart:sky"; |
9 | 9 |
10 class _Registration { | 10 class _Registration { |
(...skipping 29 matching lines...) Expand all Loading... |
40 // Invoke attributeChanged callback when element is first created too. | 40 // Invoke attributeChanged callback when element is first created too. |
41 for (Attr attribute in getAttributes()) | 41 for (Attr attribute in getAttributes()) |
42 attributeChangedCallback(attribute.name, null, attribute.value); | 42 attributeChangedCallback(attribute.name, null, attribute.value); |
43 } | 43 } |
44 | 44 |
45 attachedCallback() { | 45 attachedCallback() { |
46 if (shadowRoot == null) { | 46 if (shadowRoot == null) { |
47 var registration = _registery[tagName]; | 47 var registration = _registery[tagName]; |
48 if (registration.template != null) { | 48 if (registration.template != null) { |
49 ShadowRoot shadow = ensureShadowRoot(); | 49 ShadowRoot shadow = ensureShadowRoot(); |
50 var tree = registration.template.content.cloneNode(deep:true); | 50 Node content = registration.template.content; |
51 shadow.appendChild(tree); | 51 shadow.appendChild(document.importNode(content, deep: true)); |
52 shadowRootReady(); | 52 shadowRootReady(); |
53 } | 53 } |
54 } | 54 } |
55 attached(); | 55 attached(); |
56 } | 56 } |
57 | 57 |
58 detachedCallback() { | 58 detachedCallback() { |
59 detached(); | 59 detached(); |
60 } | 60 } |
61 | 61 |
(...skipping 12 matching lines...) Expand all Loading... |
74 if (!mirror.isSubclassOf(reflectClass(SkyElement))) | 74 if (!mirror.isSubclassOf(reflectClass(SkyElement))) |
75 throw new UnsupportedError('@Tagname can only be used on descendants of SkyE
lement'); | 75 throw new UnsupportedError('@Tagname can only be used on descendants of SkyE
lement'); |
76 | 76 |
77 String tagName = _getTagName(type); | 77 String tagName = _getTagName(type); |
78 Element template = definition.querySelector('template'); | 78 Element template = definition.querySelector('template'); |
79 | 79 |
80 document.registerElement(tagName, type); | 80 document.registerElement(tagName, type); |
81 _registery[tagName] = new _Registration(template); | 81 _registery[tagName] = new _Registration(template); |
82 } | 82 } |
83 </script> | 83 </script> |
OLD | NEW |