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 * **Warning**: this class is experiental and subject to change. | 8 * **Warning**: this class is experiental and subject to change. |
9 * | 9 * |
10 * The implementation for the `polymer-element` element. | 10 * The implementation for the `polymer-element` element. |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 // setting resource paths. e.g. | 165 // setting resource paths. e.g. |
166 // this.$.image.src = this.resolvePath('images/foo.png') | 166 // this.$.image.src = this.resolvePath('images/foo.png') |
167 // Potentially remove when spec bug is addressed. | 167 // Potentially remove when spec bug is addressed. |
168 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=21407 | 168 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=21407 |
169 // TODO(jmesserly): resolvePath not ported, see first comment in this class. | 169 // TODO(jmesserly): resolvePath not ported, see first comment in this class. |
170 | 170 |
171 // under ShadowDOMPolyfill, transforms to approximate missing CSS features | 171 // under ShadowDOMPolyfill, transforms to approximate missing CSS features |
172 _shimShadowDomStyling(templateContent, name); | 172 _shimShadowDomStyling(templateContent, name); |
173 | 173 |
174 // register our custom element | 174 // register our custom element |
175 registerType(name, extendsTag: extendee); | 175 registerType(name); |
176 | 176 |
177 // NOTE: skip in Dart because we don't have mutable global scope. | 177 // NOTE: skip in Dart because we don't have mutable global scope. |
178 // reference constructor in a global named by 'constructor' attribute | 178 // reference constructor in a global named by 'constructor' attribute |
179 // publishConstructor(); | 179 // publishConstructor(); |
180 } | 180 } |
181 | 181 |
182 /** | 182 /** |
183 * Gets the Dart type registered for this name, and sets up declarative | 183 * Gets the Dart type registered for this name, and sets up declarative |
184 * features. Fills in the [type] and [supertype] fields. | 184 * features. Fills in the [type] and [supertype] fields. |
185 * | 185 * |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 // TODO(jmesserly): this feels unnatrual in Dart. Since we have convenient | 227 // TODO(jmesserly): this feels unnatrual in Dart. Since we have convenient |
228 // lazy static initialization, can we get by without it? | 228 // lazy static initialization, can we get by without it? |
229 var registered = cls.methods[#registerCallback]; | 229 var registered = cls.methods[#registerCallback]; |
230 if (registered != null && registered.isStatic && | 230 if (registered != null && registered.isStatic && |
231 registered.isRegularMethod) { | 231 registered.isRegularMethod) { |
232 cls.invoke(#registerCallback, [this]); | 232 cls.invoke(#registerCallback, [this]); |
233 } | 233 } |
234 | 234 |
235 } | 235 } |
236 | 236 |
237 void registerType(String name, {String extendsTag}) { | 237 void registerType(String name) { |
Jennifer Messerly
2013/10/22 21:41:47
retroactive question: why don't we pass in "extend
| |
238 var baseTag; | |
239 var decl = this; | |
240 while (decl != null) { | |
241 baseTag = decl.attributes['extends']; | |
242 decl = decl.superDeclaration; | |
243 } | |
238 // native element must be specified in extends | 244 // native element must be specified in extends |
239 var nativeExtends = (extendsTag != null && !extendsTag.contains('-')) ? | 245 var nativeExtends = baseTag; |
Siggi Cherem (dart-lang)
2013/10/22 16:44:17
nit: merge baseTag or nativeExtends to use a singl
| |
240 extendsTag : null; | |
241 document.register(name, type, extendsTag: nativeExtends); | 246 document.register(name, type, extendsTag: nativeExtends); |
242 } | 247 } |
243 | 248 |
244 void publishAttributes(ClassMirror cls, PolymerDeclaration superDecl) { | 249 void publishAttributes(ClassMirror cls, PolymerDeclaration superDecl) { |
245 // get properties to publish | 250 // get properties to publish |
246 if (superDecl != null && superDecl._publish != null) { | 251 if (superDecl != null && superDecl._publish != null) { |
247 _publish = new Map.from(superDecl._publish); | 252 _publish = new Map.from(superDecl._publish); |
248 } | 253 } |
249 _publish = _getProperties(cls, _publish, (x) => x is PublishedProperty); | 254 _publish = _getProperties(cls, _publish, (x) => x is PublishedProperty); |
250 | 255 |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
677 return map; | 682 return map; |
678 }(); | 683 }(); |
679 | 684 |
680 // Dart note: we need this function because we have additional renames JS does | 685 // Dart note: we need this function because we have additional renames JS does |
681 // not have. The JS renames are simply case differences, whereas we have ones | 686 // not have. The JS renames are simply case differences, whereas we have ones |
682 // like doubleclick -> dblclick and stripping the webkit prefix. | 687 // like doubleclick -> dblclick and stripping the webkit prefix. |
683 String _eventNameFromType(String eventType) { | 688 String _eventNameFromType(String eventType) { |
684 final result = _reverseEventTranslations[eventType]; | 689 final result = _reverseEventTranslations[eventType]; |
685 return result != null ? result : eventType; | 690 return result != null ? result : eventType; |
686 } | 691 } |
OLD | NEW |