Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: sky/framework/sky-element.sky

Issue 943153002: Make it possible for sky-element to register any tag name (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/dom/Element.idl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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>
OLDNEW
« no previous file with comments | « sky/engine/core/dom/Element.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698