| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of polymer; | 5 part of polymer; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Use this annotation to publish a field as an attribute. For example: | 8 * Use this annotation to publish a field as an attribute. For example: |
| 9 * | 9 * |
| 10 * class MyPlaybackElement extends PolymerElement { | 10 * class MyPlaybackElement extends PolymerElement { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 Job job(Job job, void callback(), Duration wait) => | 127 Job job(Job job, void callback(), Duration wait) => |
| 128 runJob(job, callback, wait); | 128 runJob(job, callback, wait); |
| 129 | 129 |
| 130 void polymerCreated() { | 130 void polymerCreated() { |
| 131 if (this.ownerDocument.window != null || alwaysPrepare || | 131 if (this.ownerDocument.window != null || alwaysPrepare || |
| 132 _preparingElements > 0) { | 132 _preparingElements > 0) { |
| 133 prepareElement(); | 133 prepareElement(); |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 /** Retrieves the custom element name by inspecting the host node. */ |
| 138 String get _customTagName { |
| 139 var isAttr = attributes['is']; |
| 140 return (isAttr == null || isAttr == '') ? localName : isAttr; |
| 141 } |
| 142 |
| 137 void prepareElement() { | 143 void prepareElement() { |
| 138 // Dart note: get the _declaration, which also marks _elementPrepared | 144 // Dart note: get the _declaration, which also marks _elementPrepared |
| 139 _declaration = _getDeclaration(this.runtimeType); | 145 _declaration = _getDeclaration(_customTagName); |
| 140 // do this first so we can observe changes during initialization | 146 // do this first so we can observe changes during initialization |
| 141 observeProperties(); | 147 observeProperties(); |
| 142 // install boilerplate attributes | 148 // install boilerplate attributes |
| 143 copyInstanceAttributes(); | 149 copyInstanceAttributes(); |
| 144 // process input attributes | 150 // process input attributes |
| 145 takeAttributes(); | 151 takeAttributes(); |
| 146 // add event listeners | 152 // add event listeners |
| 147 addHostListeners(); | 153 addHostListeners(); |
| 148 // guarantees that while preparing, any sub-elements will also be prepared | 154 // guarantees that while preparing, any sub-elements will also be prepared |
| 149 _preparingElements++; | 155 _preparingElements++; |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 /** | 960 /** |
| 955 * Base class for PolymerElements deriving from HtmlElement. | 961 * Base class for PolymerElements deriving from HtmlElement. |
| 956 * | 962 * |
| 957 * See [Polymer]. | 963 * See [Polymer]. |
| 958 */ | 964 */ |
| 959 class PolymerElement extends HtmlElement with Polymer, Observable { | 965 class PolymerElement extends HtmlElement with Polymer, Observable { |
| 960 PolymerElement.created() : super.created() { | 966 PolymerElement.created() : super.created() { |
| 961 polymerCreated(); | 967 polymerCreated(); |
| 962 } | 968 } |
| 963 } | 969 } |
| OLD | NEW |