| 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 16 matching lines...) Expand all Loading... |
| 27 abstract class SkyElement extends Element { | 27 abstract class SkyElement extends Element { |
| 28 // Override these functions to receive lifecycle notifications. | 28 // Override these functions to receive lifecycle notifications. |
| 29 void created() {} | 29 void created() {} |
| 30 void attached() {} | 30 void attached() {} |
| 31 void detached() {} | 31 void detached() {} |
| 32 void attributeChanged(String attrName, String oldValue, String newValue) {} | 32 void attributeChanged(String attrName, String oldValue, String newValue) {} |
| 33 void shadowRootReady() {} | 33 void shadowRootReady() {} |
| 34 | 34 |
| 35 String get tagName => _getTagName(runtimeType); | 35 String get tagName => _getTagName(runtimeType); |
| 36 | 36 |
| 37 // TODO(abarth): Rather than hard-coding "example" here, we should make the | 37 SkyElement() { |
| 38 // bindings read the |tagName| property of this object during construction. | |
| 39 SkyElement() : super("example") { | |
| 40 created(); | 38 created(); |
| 41 | 39 |
| 42 // Invoke attributeChanged callback when element is first created too. | 40 // Invoke attributeChanged callback when element is first created too. |
| 43 for (Attr attribute in getAttributes()) | 41 for (Attr attribute in getAttributes()) |
| 44 attributeChangedCallback(attribute.name, null, attribute.value); | 42 attributeChangedCallback(attribute.name, null, attribute.value); |
| 45 } | 43 } |
| 46 | 44 |
| 47 attachedCallback() { | 45 attachedCallback() { |
| 48 if (shadowRoot == null) { | 46 if (shadowRoot == null) { |
| 49 var registration = _registery[tagName]; | 47 var registration = _registery[tagName]; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 76 if (!mirror.isSubclassOf(reflectClass(SkyElement))) | 74 if (!mirror.isSubclassOf(reflectClass(SkyElement))) |
| 77 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'); |
| 78 | 76 |
| 79 String tagName = _getTagName(type); | 77 String tagName = _getTagName(type); |
| 80 Element template = definition.querySelector('template'); | 78 Element template = definition.querySelector('template'); |
| 81 | 79 |
| 82 document.registerElement(tagName, type); | 80 document.registerElement(tagName, type); |
| 83 _registery[tagName] = new _Registration(template); | 81 _registery[tagName] = new _Registration(template); |
| 84 } | 82 } |
| 85 </script> | 83 </script> |
| OLD | NEW |