| OLD | NEW |
| 1 part of angular.core; | 1 part of angular.core; |
| 2 | 2 |
| 3 abstract class NgAnnotation { | 3 abstract class NgAnnotation { |
| 4 /** | 4 /** |
| 5 * CSS selector which will trigger this component/directive. | 5 * CSS selector which will trigger this component/directive. |
| 6 * CSS Selectors are limited to a single element and can contain: | 6 * CSS Selectors are limited to a single element and can contain: |
| 7 * | 7 * |
| 8 * * `element-name` limit to a given element name. | 8 * * `element-name` limit to a given element name. |
| 9 * * `.class` limit to an element with a given class. | 9 * * `.class` limit to an element with a given class. |
| 10 * * `[attribute]` limit to an element with a given attribute name. | 10 * * `[attribute]` limit to an element with a given attribute name. |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 children: NgAnnotation.COMPILE_CHILDREN, | 238 children: NgAnnotation.COMPILE_CHILDREN, |
| 239 visibility: visibility, | 239 visibility: visibility, |
| 240 publishTypes: publishTypes, | 240 publishTypes: publishTypes, |
| 241 publishAs: publishAs, | 241 publishAs: publishAs, |
| 242 map: map, | 242 map: map, |
| 243 exportExpressions: exportExpressions, | 243 exportExpressions: exportExpressions, |
| 244 exportExpressionAttrs: exportExpressionAttrs); | 244 exportExpressionAttrs: exportExpressionAttrs); |
| 245 | 245 |
| 246 NgAnnotation cloneWithNewMap(newMap) => | 246 NgAnnotation cloneWithNewMap(newMap) => |
| 247 new NgComponent( | 247 new NgComponent( |
| 248 template: this.template, | 248 template: template, |
| 249 templateUrl: this.templateUrl, | 249 templateUrl: templateUrl, |
| 250 cssUrls: this.cssUrls, | 250 cssUrl: cssUrl, |
| 251 applyAuthorStyles: this.applyAuthorStyles, | 251 cssUrls: cssUrls, |
| 252 resetStyleInheritance: this.resetStyleInheritance, | 252 applyAuthorStyles: applyAuthorStyles, |
| 253 publishAs: this.publishAs, | 253 resetStyleInheritance: resetStyleInheritance, |
| 254 publishAs: publishAs, |
| 254 map: newMap, | 255 map: newMap, |
| 255 selector: this.selector, | 256 selector: selector, |
| 256 visibility: this.visibility, | 257 visibility: visibility, |
| 257 publishTypes: this.publishTypes, | 258 publishTypes: publishTypes, |
| 258 exportExpressions: this.exportExpressions, | 259 exportExpressions: exportExpressions, |
| 259 exportExpressionAttrs: this.exportExpressionAttrs); | 260 exportExpressionAttrs: exportExpressionAttrs); |
| 260 } | 261 } |
| 261 | 262 |
| 262 RegExp _ATTR_NAME = new RegExp(r'\[([^\]]+)\]$'); | 263 RegExp _ATTR_NAME = new RegExp(r'\[([^\]]+)\]$'); |
| 263 | 264 |
| 264 /** | 265 /** |
| 265 * Meta-data marker placed on a class which should act as a directive. | 266 * Meta-data marker placed on a class which should act as a directive. |
| 266 * | 267 * |
| 267 * Angular directives are instantiated using dependency injection, and can | 268 * Angular directives are instantiated using dependency injection, and can |
| 268 * ask for any injectable object in their constructor. Directives | 269 * ask for any injectable object in their constructor. Directives |
| 269 * can also ask for other components or directives declared on the DOM element. | 270 * can also ask for other components or directives declared on the DOM element. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 288 publishTypes : const <Type>[], | 289 publishTypes : const <Type>[], |
| 289 exportExpressions, | 290 exportExpressions, |
| 290 exportExpressionAttrs | 291 exportExpressionAttrs |
| 291 }) : super(selector: selector, children: children, visibilit
y: visibility, | 292 }) : super(selector: selector, children: children, visibilit
y: visibility, |
| 292 publishTypes: publishTypes, publishAs: publishAs, map: map, | 293 publishTypes: publishTypes, publishAs: publishAs, map: map, |
| 293 exportExpressions: exportExpressions, | 294 exportExpressions: exportExpressions, |
| 294 exportExpressionAttrs: exportExpressionAttrs); | 295 exportExpressionAttrs: exportExpressionAttrs); |
| 295 | 296 |
| 296 NgAnnotation cloneWithNewMap(newMap) => | 297 NgAnnotation cloneWithNewMap(newMap) => |
| 297 new NgDirective( | 298 new NgDirective( |
| 298 children: this.children, | 299 children: children, |
| 299 publishAs: this.publishAs, | 300 publishAs: publishAs, |
| 300 map: newMap, | 301 map: newMap, |
| 301 selector: this.selector, | 302 selector: selector, |
| 302 visibility: this.visibility, | 303 visibility: visibility, |
| 303 publishTypes: this.publishTypes, | 304 publishTypes: publishTypes, |
| 304 exportExpressions: this.exportExpressions, | 305 exportExpressions: exportExpressions, |
| 305 exportExpressionAttrs: this.exportExpressionAttrs); | 306 exportExpressionAttrs: exportExpressionAttrs); |
| 306 } | 307 } |
| 307 | 308 |
| 308 /** | 309 /** |
| 309 * Meta-data marker placed on a class which should act as a controller for your
application. | 310 * Meta-data marker placed on a class which should act as a controller for your
application. |
| 310 * | 311 * |
| 311 * Controllers are essentially [NgDirectives] with few key differences: | 312 * Controllers are essentially [NgDirective]s with few key differences: |
| 312 * | 313 * |
| 313 * * Controllers create a new scope at the element. | 314 * * Controllers create a new scope at the element. |
| 314 * * Controllers should not do any DOM manipulation. | 315 * * Controllers should not do any DOM manipulation. |
| 315 * * Controllers are meant for application-logic | 316 * * Controllers are meant for application-logic |
| 316 * (rather then DOM monipulation logic which directives are meant for.) | 317 * (rather then DOM monipulation logic which directives are meant for.) |
| 317 * | 318 * |
| 318 * Controllers can implement [NgAttachAware], [NgDetachAware] and | 319 * Controllers can implement [NgAttachAware], [NgDetachAware] and |
| 319 * declare these optional methods: | 320 * declare these optional methods: |
| 320 * | 321 * |
| 321 * * `attach()` - Called on first [Scope.$digest()]. | 322 * * `attach()` - Called on first [Scope.$digest()]. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 335 publishTypes : const <Type>[], | 336 publishTypes : const <Type>[], |
| 336 exportExpressions, | 337 exportExpressions, |
| 337 exportExpressionAttrs | 338 exportExpressionAttrs |
| 338 }) : super(selector: selector, children: children, visibilit
y: visibility, | 339 }) : super(selector: selector, children: children, visibilit
y: visibility, |
| 339 publishTypes: publishTypes, publishAs: publishAs, map: map, | 340 publishTypes: publishTypes, publishAs: publishAs, map: map, |
| 340 exportExpressions: exportExpressions, | 341 exportExpressions: exportExpressions, |
| 341 exportExpressionAttrs: exportExpressionAttrs); | 342 exportExpressionAttrs: exportExpressionAttrs); |
| 342 | 343 |
| 343 NgAnnotation cloneWithNewMap(newMap) => | 344 NgAnnotation cloneWithNewMap(newMap) => |
| 344 new NgController( | 345 new NgController( |
| 345 children: this.children, | 346 children: children, |
| 346 publishAs: this.publishAs, | 347 publishAs: publishAs, |
| 347 map: newMap, | 348 map: newMap, |
| 348 selector: this.selector, | 349 selector: selector, |
| 349 visibility: this.visibility, | 350 visibility: visibility, |
| 350 publishTypes: this.publishTypes, | 351 publishTypes: publishTypes, |
| 351 exportExpressions: this.exportExpressions, | 352 exportExpressions: exportExpressions, |
| 352 exportExpressionAttrs: this.exportExpressionAttrs); | 353 exportExpressionAttrs: exportExpressionAttrs); |
| 353 } | 354 } |
| 354 | 355 |
| 355 abstract class AttrFieldAnnotation { | 356 abstract class AttrFieldAnnotation { |
| 356 final String attrName; | 357 final String attrName; |
| 357 const AttrFieldAnnotation(this.attrName); | 358 const AttrFieldAnnotation(this.attrName); |
| 358 String get mappingSpec; | 359 String get mappingSpec; |
| 359 } | 360 } |
| 360 | 361 |
| 361 /** | 362 /** |
| 362 * When applied as an annotation on a directive field specifies that | 363 * When applied as an annotation on a directive field specifies that |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 | 426 |
| 426 /** | 427 /** |
| 427 * Implementing directives or components [detach] method will be called when | 428 * Implementing directives or components [detach] method will be called when |
| 428 * the associated scope is destroyed. | 429 * the associated scope is destroyed. |
| 429 */ | 430 */ |
| 430 abstract class NgDetachAware { | 431 abstract class NgDetachAware { |
| 431 void detach(); | 432 void detach(); |
| 432 } | 433 } |
| 433 | 434 |
| 434 @NgInjectableService() | 435 @NgInjectableService() |
| 435 class DirectiveMap extends AnnotationMap<NgAnnotation> { | 436 class DirectiveMap extends AnnotationsMap<NgAnnotation> { |
| 436 DirectiveMap(Injector injector, MetadataExtractor metadataExtractor, | 437 DirectiveMap(Injector injector, MetadataExtractor metadataExtractor, |
| 437 FieldMetadataExtractor fieldMetadataExtractor) | 438 FieldMetadataExtractor fieldMetadataExtractor) |
| 438 : super(injector, metadataExtractor) { | 439 : super(injector, metadataExtractor) { |
| 439 Map<NgAnnotation, Type> directives = {}; | 440 Map<NgAnnotation, List<Type>> directives = {}; |
| 440 forEach((NgAnnotation annotation, Type type) { | 441 forEach((NgAnnotation annotation, Type type) { |
| 441 var match; | 442 var match; |
| 442 var fieldMetadata = fieldMetadataExtractor(type); | 443 var fieldMetadata = fieldMetadataExtractor(type); |
| 443 if (fieldMetadata.isNotEmpty) { | 444 if (fieldMetadata.isNotEmpty) { |
| 444 var newMap = annotation.map == null ? {} : new Map.from(annotation.map); | 445 var newMap = annotation.map == null ? {} : new Map.from(annotation.map); |
| 445 fieldMetadata.forEach((String fieldName, AttrFieldAnnotation ann) { | 446 fieldMetadata.forEach((String fieldName, AttrFieldAnnotation ann) { |
| 446 var attrName = ann.attrName; | 447 var attrName = ann.attrName; |
| 447 if (newMap.containsKey(attrName)) { | 448 if (newMap.containsKey(attrName)) { |
| 448 throw 'Mapping for attribute $attrName is already defined (while ' | 449 throw 'Mapping for attribute $attrName is already defined (while ' |
| 449 'processing annottation for field $fieldName of $type)'; | 450 'processing annottation for field $fieldName of $type)'; |
| 450 } | 451 } |
| 451 newMap[attrName] = '${ann.mappingSpec}$fieldName'; | 452 newMap[attrName] = '${ann.mappingSpec}$fieldName'; |
| 452 }); | 453 }); |
| 453 annotation = annotation.cloneWithNewMap(newMap); | 454 annotation = annotation.cloneWithNewMap(newMap); |
| 454 } | 455 } |
| 455 directives[annotation] = type; | 456 directives.putIfAbsent(annotation, () => []).add(type); |
| 456 }); | 457 }); |
| 457 _map.clear(); | 458 _map.clear(); |
| 458 _map.addAll(directives); | 459 _map.addAll(directives); |
| 459 } | 460 } |
| 460 } | 461 } |
| 461 | 462 |
| 462 @NgInjectableService() | 463 @NgInjectableService() |
| 463 class FieldMetadataExtractor { | 464 class FieldMetadataExtractor { |
| 464 List<TypeMirror> _fieldAnnotations = [reflectType(NgAttr), | 465 List<TypeMirror> _fieldAnnotations = [reflectType(NgAttr), |
| 465 reflectType(NgOneWay), reflectType(NgOneWayOneTime), | 466 reflectType(NgOneWay), reflectType(NgOneWayOneTime), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 483 'than once in $type'; | 484 'than once in $type'; |
| 484 } | 485 } |
| 485 fields[fieldName] = meta.reflectee as AttrFieldAnnotation; | 486 fields[fieldName] = meta.reflectee as AttrFieldAnnotation; |
| 486 } | 487 } |
| 487 }); | 488 }); |
| 488 } | 489 } |
| 489 }); | 490 }); |
| 490 return fields; | 491 return fields; |
| 491 } | 492 } |
| 492 } | 493 } |
| OLD | NEW |