Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: third_party/pkg/angular/lib/core/directive.dart

Issue 256553002: Revert "Update all Angular libs (run update_all.sh)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/lib/core/directive.dart
diff --git a/third_party/pkg/angular/lib/core/annotation_src.dart b/third_party/pkg/angular/lib/core/directive.dart
similarity index 54%
rename from third_party/pkg/angular/lib/core/annotation_src.dart
rename to third_party/pkg/angular/lib/core/directive.dart
index ee5270362408878aae0dfbc55a5c15309b69a6ce..63fd69a0f399265c0802e00cad8e36877290f71f 100644
--- a/third_party/pkg/angular/lib/core/annotation_src.dart
+++ b/third_party/pkg/angular/lib/core/directive.dart
@@ -1,55 +1,6 @@
-library angular.core.annotation_src;
-
-import "package:di/di.dart" show Injector, Visibility;
-
-RegExp _ATTR_NAME = new RegExp(r'\[([^\]]+)\]$');
-
-const String SHADOW_DOM_INJECTOR_NAME = 'SHADOW_INJECTOR';
-
-skipShadow(Injector injector)
- => injector.name == SHADOW_DOM_INJECTOR_NAME ? injector.parent : injector;
-
-localVisibility (Injector requesting, Injector defining)
- => identical(skipShadow(requesting), defining);
-
-directChildrenVisibility(Injector requesting, Injector defining) {
- requesting = skipShadow(requesting);
- return identical(requesting.parent, defining) || localVisibility(requesting, defining);
-}
-
-Directive cloneWithNewMap(Directive annotation, map)
- => annotation._cloneWithNewMap(map);
-
-String mappingSpec(DirectiveAnnotation annotation) => annotation._mappingSpec;
-
-
-/**
- * An annotation when applied to a class indicates that the class (service) will
- * be instantiated by di injector. This annotation is also used to designate which
- * classes need to have a static factory generated when using static angular, and
- * therefore is required on any injectable class.
- */
-class Injectable {
- const Injectable();
-}
-
-/**
- * Abstract supper class of [Controller], [Component], and [Decorator].
- */
-abstract class Directive {
-
- /// The directive can only be injected to other directives on the same element.
- static const Visibility LOCAL_VISIBILITY = localVisibility;
-
- /// The directive can be injected to other directives on the same or child elements.
- static const Visibility CHILDREN_VISIBILITY = null;
-
- /**
- * The directive on this element can only be injected to other directives
- * declared on elements which are direct children of the current element.
- */
- static const Visibility DIRECT_CHILDREN_VISIBILITY = directChildrenVisibility;
+part of angular.core;
+abstract class NgAnnotation {
/**
* CSS selector which will trigger this component/directive.
* CSS Selectors are limited to a single element and can contain:
@@ -58,7 +9,6 @@ abstract class Directive {
* * `.class` limit to an element with a given class.
* * `[attribute]` limit to an element with a given attribute name.
* * `[attribute=value]` limit to an element with a given attribute and value.
- * * `:contains(/abc/)` limit to an element which contains the given text.
*
*
* Example: `input[type=checkbox][ng-model]`
@@ -73,25 +23,21 @@ abstract class Directive {
* * [TRANSCLUDE_CHILDREN]
* * [IGNORE_CHILDREN]
*/
- @deprecated
final String children;
/**
* Compile the child nodes of the element. This is the default.
*/
- @deprecated
static const String COMPILE_CHILDREN = 'compile';
/**
* Compile the child nodes for transclusion and makes available
- * [BoundViewFactory], [ViewFactory] and [ViewPort] for injection.
+ * [BoundBlockFactory], [BlockFactory] and [BlockHole] for injection.
*/
- @deprecated
static const String TRANSCLUDE_CHILDREN = 'transclude';
/**
* Do not compile/visit the child nodes. Angular markup on descendant nodes
* will not be processed.
*/
- @deprecated
static const String IGNORE_CHILDREN = 'ignore';
/**
@@ -99,40 +45,17 @@ abstract class Directive {
* directives/components. This attribute controls whether the
* controller is available to others.
*
- * * `local` [Directive.LOCAL_VISIBILITY] - the controller can be injected
+ * * `local` [NgDirective.LOCAL_VISIBILITY] - the controller can be injected
* into other directives / components on the same DOM element.
- * * `children` [Directive.CHILDREN_VISIBILITY] - the controller can be
+ * * `children` [NgDirective.CHILDREN_VISIBILITY] - the controller can be
* injected into other directives / components on the same or child DOM
* elements.
- * * `direct_children` [Directive.DIRECT_CHILDREN_VISIBILITY] - the
+ * * `direct_children` [NgDirective.DIRECT_CHILDREN_VISIBILITY] - the
* controller can be injected into other directives / components on the
* direct children of the current DOM element.
*/
- final Visibility visibility;
-
- /**
- * A directive/component class can publish types by using a factory
- * function to generate a module. The module is then installed into
- * the injector at that element. Any types declared in the module then
- * become available for injection.
- *
- * Example:
- *
- * @Decorator(
- * selector: '[foo]',
- * module: Foo.moduleFactory)
- * class Foo {
- * static moduleFactory() => new Module()
- * ..type(SomeTypeA, visibility: Directive.LOCAL_VISIBILITY);
- * }
- *
- * When specifying types, factories or values in the module, notice that
- * `Visibility` maps to:
- * * [Directive.LOCAL_VISIBILITY]
- * * [Directive.CHILDREN_VISIBILITY]
- * * [Directive.DIRECT_CHILDREN_VISIBILITY]
- */
- final Function module;
+ final String visibility;
+ final List<Type> publishTypes;
/**
* Use map to define the mapping of DOM attributes to fields.
@@ -168,12 +91,14 @@ abstract class Directive {
* selection="selectedItem"
* on-selection-change="doSomething()">
*
- * @Component(
+ * @NgComponent(
* selector: 'my-component'
* map: const {
* 'title': '@title',
* 'selection': '<=>currentItem',
- * 'on-selection-change': '&onChange'})
+ * 'on-selection-change': '&onChange'
+ * }
+ * )
* class MyComponent {
* String title;
* var currentItem;
@@ -200,24 +125,22 @@ abstract class Directive {
final Map<String, String> map;
/**
- * Use the list to specify expressions containing attributes which are not
- * included under [map] with '=' or '@' specification. This is used by
- * angular transformer during deployment.
+ * Use the list to specify expression containing attributes which are not
+ * included under [map] with '=' or '@' specification.
*/
final List<String> exportExpressionAttrs;
/**
- * Use the list to specify expressions which are evaluated dynamically
+ * Use the list to specify a expressions which are evaluated dynamically
* (ex. via [Scope.eval]) and are otherwise not statically discoverable.
- * This is used by angular transformer during deployment.
*/
final List<String> exportExpressions;
- const Directive({
+ const NgAnnotation({
this.selector,
- this.children: Directive.COMPILE_CHILDREN,
- this.visibility: Directive.LOCAL_VISIBILITY,
- this.module,
+ this.children: NgAnnotation.COMPILE_CHILDREN,
+ this.visibility: NgDirective.LOCAL_VISIBILITY,
+ this.publishTypes: const [],
this.map: const {},
this.exportExpressions: const [],
this.exportExpressionAttrs: const []
@@ -226,15 +149,12 @@ abstract class Directive {
toString() => selector;
get hashCode => selector.hashCode;
operator==(other) =>
- other is Directive && selector == other.selector;
+ other is NgAnnotation && this.selector == other.selector;
- Directive _cloneWithNewMap(newMap);
+ NgAnnotation cloneWithNewMap(newMap);
}
-bool _applyAuthorStylesDeprecationWarningPrinted = false;
-bool _resetStyleInheritanceDeprecationWarningPrinted = false;
-
/**
* Meta-data marker placed on a class which should act as a controller for the
* component. Angular components are a light-weight version of web-components.
@@ -244,14 +164,14 @@ bool _resetStyleInheritanceDeprecationWarningPrinted = false;
* ask for any injectable object in their constructor. Components
* can also ask for other components or directives declared on the DOM element.
*
- * Components can implement [AttachAware], [DetachAware],
- * [ShadowRootAware] and declare these optional methods:
+ * Components can implement [NgAttachAware], [NgDetachAware],
+ * [NgShadowRootAware] and declare these optional methods:
*
* * `attach()` - Called on first [Scope.apply()].
* * `detach()` - Called on when owning scope is destroyed.
* * `onShadowRoot(ShadowRoot shadowRoot)` - Called when [ShadowRoot] is loaded.
*/
-class Component extends Directive {
+class NgComponent extends NgAnnotation {
/**
* Inlined HTML template for the component.
*/
@@ -271,72 +191,41 @@ class Component extends Directive {
/**
* Set the shadow root applyAuthorStyles property. See shadow-DOM
* documentation for further details.
- *
- * This feature will be removed in Chrome 35.
*/
- @deprecated
- bool get applyAuthorStyles {
- if (!_applyAuthorStylesDeprecationWarningPrinted && _applyAuthorStyles == true) {
- print("WARNING applyAuthorStyles is deprecated in component $selector");
- _applyAuthorStylesDeprecationWarningPrinted = true;
- }
- return _applyAuthorStyles;
- }
- final bool _applyAuthorStyles;
+ final bool applyAuthorStyles;
/**
* Set the shadow root resetStyleInheritance property. See shadow-DOM
* documentation for further details.
- *
- * This feature will be removed in Chrome 35.
*/
- @deprecated
- bool get resetStyleInheritance {
- if (!_resetStyleInheritanceDeprecationWarningPrinted && _resetStyleInheritance == true) {
- print("WARNING resetStyleInheritance is deprecated in component $selector");
- _resetStyleInheritanceDeprecationWarningPrinted = true;
- }
- return _resetStyleInheritance;
- }
- final bool _resetStyleInheritance;
+ final bool resetStyleInheritance;
/**
* An expression under which the component's controller instance will be
* published into. This allows the expressions in the template to be referring
* to controller instance and its properties.
*/
- @deprecated
final String publishAs;
- /**
- * If set to true, this component will always use shadow DOM.
- * If set to false, this component will never use shadow DOM.
- * If unset, the compiler's default construction strategy will be used
- */
- final bool useShadowDom;
-
- const Component({
+ const NgComponent({
this.template,
this.templateUrl,
cssUrl,
- applyAuthorStyles,
- resetStyleInheritance,
+ this.applyAuthorStyles,
+ this.resetStyleInheritance,
this.publishAs,
- module,
map,
selector,
visibility,
+ publishTypes : const <Type>[],
exportExpressions,
- exportExpressionAttrs,
- this.useShadowDom})
+ exportExpressionAttrs})
: _cssUrls = cssUrl,
- _applyAuthorStyles = applyAuthorStyles,
- _resetStyleInheritance = resetStyleInheritance,
super(selector: selector,
- children: Directive.COMPILE_CHILDREN,
+ children: NgAnnotation.COMPILE_CHILDREN,
visibility: visibility,
+ publishTypes: publishTypes,
map: map,
- module: module,
exportExpressions: exportExpressions,
exportExpressionAttrs: exportExpressionAttrs);
@@ -344,8 +233,8 @@ class Component extends Directive {
const [] :
_cssUrls is List ? _cssUrls : [_cssUrls];
- Directive _cloneWithNewMap(newMap) =>
- new Component(
+ NgAnnotation cloneWithNewMap(newMap) =>
+ new NgComponent(
template: template,
templateUrl: templateUrl,
cssUrl: cssUrls,
@@ -353,14 +242,15 @@ class Component extends Directive {
resetStyleInheritance: resetStyleInheritance,
publishAs: publishAs,
map: newMap,
- module: module,
selector: selector,
visibility: visibility,
+ publishTypes: publishTypes,
exportExpressions: exportExpressions,
- exportExpressionAttrs: exportExpressionAttrs,
- useShadowDom: useShadowDom);
+ exportExpressionAttrs: exportExpressionAttrs);
}
+RegExp _ATTR_NAME = new RegExp(r'\[([^\]]+)\]$');
+
/**
* Meta-data marker placed on a class which should act as a directive.
*
@@ -368,58 +258,60 @@ class Component extends Directive {
* ask for any injectable object in their constructor. Directives
* can also ask for other components or directives declared on the DOM element.
*
- * Directives can implement [AttachAware], [DetachAware] and
+ * Directives can implement [NgAttachAware], [NgDetachAware] and
* declare these optional methods:
*
* * `attach()` - Called on first [Scope.apply()].
* * `detach()` - Called on when owning scope is destroyed.
*/
-class Decorator extends Directive {
- const Decorator({children: Directive.COMPILE_CHILDREN,
+class NgDirective extends NgAnnotation {
+ static const String LOCAL_VISIBILITY = 'local';
+ static const String CHILDREN_VISIBILITY = 'children';
+ static const String DIRECT_CHILDREN_VISIBILITY = 'direct_children';
+
+ const NgDirective({children: NgAnnotation.COMPILE_CHILDREN,
map,
selector,
- module,
visibility,
+ publishTypes : const <Type>[],
exportExpressions,
- exportExpressionAttrs})
- : super(selector: selector,
- children: children,
- visibility: visibility,
- map: map,
- module: module,
- exportExpressions: exportExpressions,
- exportExpressionAttrs: exportExpressionAttrs);
-
- Directive _cloneWithNewMap(newMap) =>
- new Decorator(
+ exportExpressionAttrs}) : super(selector: selector, children: children, visibility: visibility,
+ publishTypes: publishTypes, map: map,
+ exportExpressions: exportExpressions,
+ exportExpressionAttrs: exportExpressionAttrs);
+
+ NgAnnotation cloneWithNewMap(newMap) =>
+ new NgDirective(
children: children,
map: newMap,
- module: module,
selector: selector,
visibility: visibility,
+ publishTypes: publishTypes,
exportExpressions: exportExpressions,
exportExpressionAttrs: exportExpressionAttrs);
}
/**
- * Meta-data marker placed on a class which should act as a controller for your
- * application.
+ * Meta-data marker placed on a class which should act as a controller for your application.
*
- * Controllers are essentially [Decorator]s with few key differences:
+ * Controllers are essentially [NgDirective]s with few key differences:
*
* * Controllers create a new scope at the element.
* * Controllers should not do any DOM manipulation.
* * Controllers are meant for application-logic
- * (rather then DOM manipulation logic which directives are meant for.)
+ * (rather then DOM monipulation logic which directives are meant for.)
*
- * Controllers can implement [AttachAware], [DetachAware] and
+ * Controllers can implement [NgAttachAware], [NgDetachAware] and
* declare these optional methods:
*
* * `attach()` - Called on first [Scope.apply()].
* * `detach()` - Called on when owning scope is destroyed.
*/
-@deprecated
-class Controller extends Decorator {
+class NgController extends NgDirective {
+ static const String LOCAL_VISIBILITY = 'local';
+ static const String CHILDREN_VISIBILITY = 'children';
+ static const String DIRECT_CHILDREN_VISIBILITY = 'direct_children';
+
/**
* An expression under which the controller instance will be published into.
* This allows the expressions in the template to be referring to controller
@@ -427,45 +319,36 @@ class Controller extends Decorator {
*/
final String publishAs;
- const Controller({
- children: Directive.COMPILE_CHILDREN,
+ const NgController({
+ children: NgAnnotation.COMPILE_CHILDREN,
this.publishAs,
map,
- module,
selector,
visibility,
+ publishTypes : const <Type>[],
exportExpressions,
exportExpressionAttrs
- })
- : super(selector: selector,
- children: children,
- visibility: visibility,
- map: map,
- module: module,
- exportExpressions: exportExpressions,
- exportExpressionAttrs: exportExpressionAttrs);
-
- Directive _cloneWithNewMap(newMap) =>
- new Controller(
+ }) : super(selector: selector, children: children, visibility: visibility,
+ publishTypes: publishTypes, map: map,
+ exportExpressions: exportExpressions,
+ exportExpressionAttrs: exportExpressionAttrs);
+
+ NgAnnotation cloneWithNewMap(newMap) =>
+ new NgController(
children: children,
publishAs: publishAs,
- module: module,
map: newMap,
selector: selector,
visibility: visibility,
+ publishTypes: publishTypes,
exportExpressions: exportExpressions,
exportExpressionAttrs: exportExpressionAttrs);
}
-/**
- * Abstract supper class of [NgAttr], [NgCallback], [NgOneWay], [NgOneWayOneTime], and [NgTwoWay].
- */
-abstract class DirectiveAnnotation {
- /// Element attribute name
+abstract class AttrFieldAnnotation {
final String attrName;
- const DirectiveAnnotation(this.attrName);
- /// Element attribute mapping mode: `@`, `=>`, `=>!`, `<=>`, and `&`.
- String get _mappingSpec;
+ const AttrFieldAnnotation(this.attrName);
+ String get mappingSpec;
}
/**
@@ -474,108 +357,70 @@ abstract class DirectiveAnnotation {
* The value of the attribute to be treated as a string, equivalent
* to `@` specification.
*/
-@deprecated
-class NgAttr extends DirectiveAnnotation {
- final _mappingSpec = '@';
+class NgAttr extends AttrFieldAnnotation {
+ final mappingSpec = '@';
const NgAttr(String attrName) : super(attrName);
}
/**
* When applied as an annotation on a directive field specifies that
* the field is to be mapped to DOM attribute with the provided [attrName].
- * The value of the attribute to be treated as a one-way expression, equivalent
+ * The value of the attribute to be treated as a one-way expession, equivalent
* to `=>` specification.
*/
-@deprecated
-class NgOneWay extends DirectiveAnnotation {
- final _mappingSpec = '=>';
+class NgOneWay extends AttrFieldAnnotation {
+ final mappingSpec = '=>';
const NgOneWay(String attrName) : super(attrName);
}
/**
* When applied as an annotation on a directive field specifies that
* the field is to be mapped to DOM attribute with the provided [attrName].
- * The value of the attribute to be treated as a one time one-way expression,
+ * The value of the attribute to be treated as a one time one-way expession,
* equivalent to `=>!` specification.
*/
-@deprecated
-class NgOneWayOneTime extends DirectiveAnnotation {
- final _mappingSpec = '=>!';
+class NgOneWayOneTime extends AttrFieldAnnotation {
+ final mappingSpec = '=>!';
const NgOneWayOneTime(String attrName) : super(attrName);
}
/**
* When applied as an annotation on a directive field specifies that
* the field is to be mapped to DOM attribute with the provided [attrName].
- * The value of the attribute to be treated as a two-way expression,
+ * The value of the attribute to be treated as a two-way expession,
* equivalent to `<=>` specification.
*/
-@deprecated
-class NgTwoWay extends DirectiveAnnotation {
- final _mappingSpec = '<=>';
+class NgTwoWay extends AttrFieldAnnotation {
+ final mappingSpec = '<=>';
const NgTwoWay(String attrName) : super(attrName);
}
/**
* When applied as an annotation on a directive field specifies that
* the field is to be mapped to DOM attribute with the provided [attrName].
- * The value of the attribute to be treated as a callback expression,
+ * The value of the attribute to be treated as a callback expession,
* equivalent to `&` specification.
*/
-@deprecated
-class NgCallback extends DirectiveAnnotation {
- final _mappingSpec = '&';
+class NgCallback extends AttrFieldAnnotation {
+ final mappingSpec = '&';
const NgCallback(String attrName) : super(attrName);
}
/**
- * A directives or components may chose to implements [AttachAware].[attach] method.
- * If implemented the method will be called when the next scope digest occurs after
- * component instantiation. It is guaranteed that when [attach] is invoked, that all
- * attribute mappings have already been processed.
+ * Implementing directives or components [attach] method will be called when
+ * the next scope digest occurs after component instantiation. It is guaranteed
+ * that when [attach] is invoked, that all attribute mappings have already
+ * been processed.
*/
-abstract class AttachAware {
+abstract class NgAttachAware {
void attach();
}
/**
- * A directives or components may chose to implements [DetachAware].[detach] method.
- * If implemented the method will be called when the next associated scope is destroyed.
+ * Implementing directives or components [detach] method will be called when
+ * the associated scope is destroyed.
*/
-abstract class DetachAware {
+abstract class NgDetachAware {
void detach();
}
-/**
- * Use @[Formatter] annotation to register a new formatter. A formatter is a class
- * with a [call] method (a callable function).
- *
- * Usage:
- *
- * // Declaration
- * @Formatter(name:'myFilter')
- * class MyFilter {
- * call(valueToFilter, optArg1, optArg2) {
- * return ...;
- * }
- * }
- *
- *
- * // Registration
- * var module = ...;
- * module.type(MyFilter);
- *
- *
- * <!-- Usage -->
- * <span>{{something | myFilter:arg1:arg2}}</span>
- */
-class Formatter {
- final String name;
-
- const Formatter({this.name});
-
- int get hashCode => name.hashCode;
- bool operator==(other) => name == other.name;
-
- toString() => 'Formatter: $name';
-}
« no previous file with comments | « third_party/pkg/angular/lib/core/cache.dart ('k') | third_party/pkg/angular/lib/core/exception_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698