| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 284         // do not override explicit entries | 284         // do not override explicit entries | 
| 285         if (attr == '') continue; | 285         if (attr == '') continue; | 
| 286 | 286 | 
| 287         var property = new Symbol(attr); | 287         var property = new Symbol(attr); | 
| 288         var path = new PropertyPath([property]); | 288         var path = new PropertyPath([property]); | 
| 289         if (_publish != null && _publish.containsKey(path)) { | 289         if (_publish != null && _publish.containsKey(path)) { | 
| 290           continue; | 290           continue; | 
| 291         } | 291         } | 
| 292 | 292 | 
| 293         var decl = smoke.getDeclaration(_type, property); | 293         var decl = smoke.getDeclaration(_type, property); | 
| 294         if (decl == null || !decl.isProperty || decl.isFinal) { | 294         if (decl == null || decl.isMethod || decl.isFinal) { | 
| 295           window.console.warn('property for attribute $attr of polymer-element ' | 295           window.console.warn('property for attribute $attr of polymer-element ' | 
| 296               'name=$name not found.'); | 296               'name=$name not found.'); | 
| 297           continue; | 297           continue; | 
| 298         } | 298         } | 
| 299         if (_publish == null) _publish = {}; | 299         if (_publish == null) _publish = {}; | 
| 300         _publish[path] = decl; | 300         _publish[path] = decl; | 
| 301       } | 301       } | 
| 302     } | 302     } | 
| 303 | 303 | 
| 304     // NOTE: the following is not possible in Dart; fields must be declared. | 304     // NOTE: the following is not possible in Dart; fields must be declared. | 
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 447     return new StyleElement() | 447     return new StyleElement() | 
| 448         ..text = cssText | 448         ..text = cssText | 
| 449         ..attributes[_STYLE_SCOPE_ATTRIBUTE] = '$name-$scopeDescriptor'; | 449         ..attributes[_STYLE_SCOPE_ATTRIBUTE] = '$name-$scopeDescriptor'; | 
| 450   } | 450   } | 
| 451 | 451 | 
| 452   /** | 452   /** | 
| 453    * Fetch a list of all *Changed methods so we can observe the associated | 453    * Fetch a list of all *Changed methods so we can observe the associated | 
| 454    * properties. | 454    * properties. | 
| 455    */ | 455    */ | 
| 456   void inferObservers() { | 456   void inferObservers() { | 
| 457     var options = const smoke.QueryOptions(includeProperties: false, | 457     var options = const smoke.QueryOptions(includeFields: false, | 
| 458         includeMethods: true, includeInherited: true); | 458         includeProperties: false, includeMethods: true, includeInherited: true); | 
| 459     for (var decl in smoke.query(_type, options)) { | 459     for (var decl in smoke.query(_type, options)) { | 
| 460       String name = smoke.symbolToName(decl.name); | 460       String name = smoke.symbolToName(decl.name); | 
| 461       if (name.endsWith(_OBSERVE_SUFFIX) && name != 'attributeChanged') { | 461       if (name.endsWith(_OBSERVE_SUFFIX) && name != 'attributeChanged') { | 
| 462         // TODO(jmesserly): now that we have a better system, should we | 462         // TODO(jmesserly): now that we have a better system, should we | 
| 463         // deprecate *Changed methods? | 463         // deprecate *Changed methods? | 
| 464         if (_observe == null) _observe = new HashMap(); | 464         if (_observe == null) _observe = new HashMap(); | 
| 465         name = name.substring(0, name.length - 7); | 465         name = name.substring(0, name.length - 7); | 
| 466         _observe[new PropertyPath(name)] = [decl.name]; | 466         _observe[new PropertyPath(name)] = [decl.name]; | 
| 467       } | 467       } | 
| 468     } | 468     } | 
| 469   } | 469   } | 
| 470 | 470 | 
| 471   /** | 471   /** | 
| 472    * Fetch a list of all methods annotated with [ObserveProperty] so we can | 472    * Fetch a list of all methods annotated with [ObserveProperty] so we can | 
| 473    * observe the associated properties. | 473    * observe the associated properties. | 
| 474    */ | 474    */ | 
| 475   void explodeObservers() { | 475   void explodeObservers() { | 
| 476     var options = const smoke.QueryOptions(includeProperties: false, | 476     var options = const smoke.QueryOptions(includeFields: false, | 
| 477         includeMethods: true, includeInherited: true, | 477         includeProperties: false, includeMethods: true, includeInherited: true, | 
| 478         withAnnotations: const [ObserveProperty]); | 478         withAnnotations: const [ObserveProperty]); | 
| 479     for (var decl in smoke.query(_type, options)) { | 479     for (var decl in smoke.query(_type, options)) { | 
| 480       for (var meta in decl.annotations) { | 480       for (var meta in decl.annotations) { | 
| 481         if (meta is! ObserveProperty) continue; | 481         if (meta is! ObserveProperty) continue; | 
| 482         if (_observe == null) _observe = new HashMap(); | 482         if (_observe == null) _observe = new HashMap(); | 
| 483         for (String name in meta.names) { | 483         for (String name in meta.names) { | 
| 484           _observe.putIfAbsent(new PropertyPath(name), () => []).add(decl.name); | 484           _observe.putIfAbsent(new PropertyPath(name), () => []).add(decl.name); | 
| 485         } | 485         } | 
| 486       } | 486       } | 
| 487     } | 487     } | 
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 644 | 644 | 
| 645 // Dart note: we need this function because we have additional renames JS does | 645 // Dart note: we need this function because we have additional renames JS does | 
| 646 // not have. The JS renames are simply case differences, whereas we have ones | 646 // not have. The JS renames are simply case differences, whereas we have ones | 
| 647 // like doubleclick -> dblclick and stripping the webkit prefix. | 647 // like doubleclick -> dblclick and stripping the webkit prefix. | 
| 648 String _eventNameFromType(String eventType) { | 648 String _eventNameFromType(String eventType) { | 
| 649   final result = _reverseEventTranslations[eventType]; | 649   final result = _reverseEventTranslations[eventType]; | 
| 650   return result != null ? result : eventType; | 650   return result != null ? result : eventType; | 
| 651 } | 651 } | 
| 652 | 652 | 
| 653 final _ATTRIBUTES_REGEX = new RegExp(r'\s|,'); | 653 final _ATTRIBUTES_REGEX = new RegExp(r'\s|,'); | 
| OLD | NEW | 
|---|