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 * **Deprecated**: use [Polymer.register] instead. | 8 * **Deprecated**: use [Polymer.register] instead. |
9 * | 9 * |
10 * Registers a [PolymerElement]. This is similar to [registerCustomElement] | 10 * Registers a [PolymerElement]. This is similar to [registerCustomElement] |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 /** The names of published properties for this polymer-element. */ | 65 /** The names of published properties for this polymer-element. */ |
66 Iterable<String> get publishedProperties => | 66 Iterable<String> get publishedProperties => |
67 _publish != null ? _publish.keys : const []; | 67 _publish != null ? _publish.keys : const []; |
68 | 68 |
69 /** Same as [_publish] but with lower case names. */ | 69 /** Same as [_publish] but with lower case names. */ |
70 Map<String, DeclarationMirror> _publishLC; | 70 Map<String, DeclarationMirror> _publishLC; |
71 | 71 |
72 Map<String, Symbol> _observe; | 72 Map<String, Symbol> _observe; |
73 | 73 |
74 Map<Symbol, Object> _instanceAttributes; | 74 Map<String, Object> _instanceAttributes; |
75 | 75 |
76 List<Element> _sheets; | 76 List<Element> _sheets; |
77 List<Element> get sheets => _sheets; | 77 List<Element> get sheets => _sheets; |
78 | 78 |
79 List<Element> _styles; | 79 List<Element> _styles; |
80 List<Element> get styles => _styles; | 80 List<Element> get styles => _styles; |
81 | 81 |
82 DocumentFragment get templateContent { | 82 DocumentFragment get templateContent { |
83 final template = query('template'); | 83 final template = query('template'); |
84 return template != null ? template.content : null; | 84 return template != null ? template.content : null; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 } | 286 } |
287 } | 287 } |
288 | 288 |
289 // NOTE: the following is not possible in Dart; fields must be declared. | 289 // NOTE: the following is not possible in Dart; fields must be declared. |
290 // install 'attributes' as properties on the prototype, | 290 // install 'attributes' as properties on the prototype, |
291 // but don't override | 291 // but don't override |
292 } | 292 } |
293 | 293 |
294 void accumulateInstanceAttributes() { | 294 void accumulateInstanceAttributes() { |
295 // inherit instance attributes | 295 // inherit instance attributes |
296 _instanceAttributes = new Map<Symbol, Object>(); | 296 _instanceAttributes = new Map<String, Object>(); |
297 if (_super != null) _instanceAttributes.addAll(_super._instanceAttributes); | 297 if (_super != null) _instanceAttributes.addAll(_super._instanceAttributes); |
298 | 298 |
299 // merge attributes from element | 299 // merge attributes from element |
300 attributes.forEach((name, value) { | 300 attributes.forEach((name, value) { |
301 if (isInstanceAttribute(name)) { | 301 if (isInstanceAttribute(name)) { |
302 _instanceAttributes[new Symbol(name)] = value; | 302 _instanceAttributes[name] = value; |
303 } | 303 } |
304 }); | 304 }); |
305 } | 305 } |
306 | 306 |
307 static bool isInstanceAttribute(name) { | 307 static bool isInstanceAttribute(name) { |
308 // do not clone these attributes onto instances | 308 // do not clone these attributes onto instances |
309 final blackList = const { | 309 final blackList = const { |
310 'name': 1, 'extends': 1, 'constructor': 1, 'noscript': 1, | 310 'name': 1, 'extends': 1, 'constructor': 1, 'noscript': 1, |
311 'attributes': 1}; | 311 'attributes': 1}; |
312 | 312 |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 return map; | 704 return map; |
705 }(); | 705 }(); |
706 | 706 |
707 // Dart note: we need this function because we have additional renames JS does | 707 // Dart note: we need this function because we have additional renames JS does |
708 // not have. The JS renames are simply case differences, whereas we have ones | 708 // not have. The JS renames are simply case differences, whereas we have ones |
709 // like doubleclick -> dblclick and stripping the webkit prefix. | 709 // like doubleclick -> dblclick and stripping the webkit prefix. |
710 String _eventNameFromType(String eventType) { | 710 String _eventNameFromType(String eventType) { |
711 final result = _reverseEventTranslations[eventType]; | 711 final result = _reverseEventTranslations[eventType]; |
712 return result != null ? result : eventType; | 712 return result != null ? result : eventType; |
713 } | 713 } |
OLD | NEW |