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

Unified Diff: third_party/pkg/angular/test/core_dom/compiler_spec.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/test/core_dom/compiler_spec.dart
diff --git a/third_party/pkg/angular/test/core_dom/compiler_spec.dart b/third_party/pkg/angular/test/core_dom/compiler_spec.dart
index f86eea9aa244aa1f61e06bfa439bfcae249cfb45..53c8c580594a95e05174bc7c1909a939eb2274ab 100644
--- a/third_party/pkg/angular/test/core_dom/compiler_spec.dart
+++ b/third_party/pkg/angular/test/core_dom/compiler_spec.dart
@@ -3,550 +3,468 @@ library compiler_spec;
import '../_specs.dart';
-forBothCompilers(fn) {
- describe('walking compiler', () {
- beforeEachModule((Module m) {
- m.type(Compiler, implementedBy: WalkingCompiler);
- return m;
- });
- fn();
- });
+main() => describe('dte.compiler', () {
+ Compiler $compile;
+ DirectiveMap directives;
+ Injector injector;
+ Scope rootScope;
- describe('tagging compiler', () {
- beforeEachModule((Module m) {
- m.type(Compiler, implementedBy: TaggingCompiler);
- return m;
- });
- fn();
- });
-
- describe('transcluding components', () {
- beforeEachModule((Module m) {
- m.type(Compiler, implementedBy: TaggingCompiler);
- m.type(ComponentFactory, implementedBy: TranscludingComponentFactory);
-
- return m;
- });
- fn();
- });
-}
-
-void main() {
- forBothCompilers(() =>
- describe('dte.compiler', () {
- TestBed _;
-
- beforeEachModule((Module module) {
+ beforeEach(module((Module module) {
module
- ..type(TabComponent)
- ..type(PublishModuleAttrDirective)
- ..type(PaneComponent)
- ..type(SimpleTranscludeInAttachAttrDirective)
- ..type(IgnoreChildrenDirective)
- ..type(IncludeTranscludeAttrDirective)
- ..type(LocalAttrDirective)
- ..type(OneOfTwoDirectives)
- ..type(TwoOfTwoDirectives)
- ..type(MyController)
- ..type(MyParentController)
- ..type(MyChildController);
- });
-
- beforeEach(inject((TestBed tb) => _ = tb));
-
- it('should compile basic hello world', () {
- var element = _.compile('<div ng-bind="name"></div>');
-
- _.rootScope.context['name'] = 'angular';
-
- expect(element.text).toEqual('');
- _.rootScope.apply();
- expect(element.text).toEqual('angular');
- });
-
- it('should not throw on an empty list', () {
- _.compile([]);
- });
-
- it('should compile a comment on the top level', () {
- _.compile('<!-- comment -->');
- expect(_.rootElements[0]).toHaveHtml('<!-- comment -->');
- });
-
- it('should compile a comment with no directives around', () {
- var element = _.compile('<div><!-- comment --></div>');
- expect(element).toHaveHtml('<!-- comment -->');
- });
-
- it('should compile a comment when the parent has a directive', () {
- var element = _.compile('<div ng-show="true"><!-- comment --></div>');
- expect(element).toHaveHtml('<!-- comment -->');
- });
-
- it('should compile a directive in a child', () {
- var element = _.compile('<div><div ng-bind="name"></div></div>');
-
- _.rootScope.context['name'] = 'angular';
-
- expect(element.text).toEqual('');
- _.rootScope.apply();
- expect(element.text).toEqual('angular');
- });
-
- it('should compile repeater', () {
- var element = _.compile('<div><div ng-repeat="item in items" ng-bind="item"></div></div>');
-
- _.rootScope.context['items'] = ['A', 'b'];
- expect(element.text).toEqual('');
-
- _.rootScope.apply();
- expect(element.text).toEqual('Ab');
-
- _.rootScope.context['items'] = [];
- _.rootScope.apply();
- expect(element).toHaveHtml('<!--ANCHOR: [ng-repeat]=item in items-->');
- });
-
- it('should compile a text child of a basic repeater', () {
- var element = _.compile(
- '<div ng-show="true">' +
- '<span ng-repeat="r in [1, 2]">{{r}}</span>' +
- '</div>');
- _.rootScope.apply();
- expect(element.text).toEqual('12');
- });
-
- it('should compile a text child of a repeat with a directive', () {
- _.compile(
- '<div ng-show="true">'
- '<span ng-show=true" ng-repeat="r in robots">{{r}}</span>'
- '</div>');
- });
-
- it('should compile a sibling template directive', () {
- var element = _.compile(
- '<div ng-model="selected">'
- '<option value="">blank</option>'
- '<div ng-repeat="value in [1,2]" ng-value="value">{{value}}</div>'
- '</div>');
-
- _.rootScope.apply();
- expect(element.text).toEqual('blank12');
- });
-
- it('should compile repeater with children', (Compiler compile) {
- var element = _.compile('<div><div ng-repeat="item in items"><div ng-bind="item"></div></div></div>');
-
- _.rootScope.context['items'] = ['A', 'b'];
-
- expect(element.text).toEqual('');
- _.rootScope.apply();
- expect(element.text).toEqual('Ab');
-
- _.rootScope.context['items'] = [];
- _.rootScope.apply();
- expect(element).toHaveHtml('<!--ANCHOR: [ng-repeat]=item in items-->');
- });
-
- it('should compile text', (Compiler compile) {
- var element = _.compile('<div>{{name}}<span>!</span></div>');
- _.rootScope.context['name'] = 'OK';
-
- microLeap();
- _.rootScope.apply();
- expect(element.text).toEqual('OK!');
- });
-
- it('should compile nested repeater', (Compiler compile) {
- var element = _.compile(
+ ..type(TabComponent)
+ ..type(PublishTypesAttrDirective)
+ ..type(PaneComponent)
+ ..type(SimpleTranscludeInAttachAttrDirective)
+ ..type(IncludeTranscludeAttrDirective)
+ ..type(LocalAttrDirective)
+ ..type(OneOfTwoDirectives)
+ ..type(TwoOfTwoDirectives)
+ ..type(MyController)
+ ..type(MyParentController)
+ ..type(MyChildController);
+ return (Injector _injector) {
+ injector = _injector;
+ $compile = injector.get(Compiler);
+ directives = injector.get(DirectiveMap);
+ rootScope = injector.get(Scope);
+ };
+ }));
+
+ it('should compile basic hello world', inject(() {
+ var element = $('<div ng-bind="name"></div>');
+ var template = $compile(element, directives);
+
+ rootScope.context['name'] = 'angular';
+ template(injector, element);
+
+ expect(element.text()).toEqual('');
+ rootScope.apply();
+ expect(element.text()).toEqual('angular');
+ }));
+
+ it('should not throw on an empty list', inject(() {
+ $compile([], directives);
+ }));
+
+ it('should compile a directive in a child', inject(() {
+ var element = $('<div><div ng-bind="name"></div></div>');
+ var template = $compile(element, directives);
+
+ rootScope.context['name'] = 'angular';
+
+
+ template(injector, element);
+
+ expect(element.text()).toEqual('');
+ rootScope.apply();
+ expect(element.text()).toEqual('angular');
+ }));
+
+ it('should compile repeater', inject(() {
+ var element = $('<div><div ng-repeat="item in items" ng-bind="item"></div></div>');
+ var template = $compile(element, directives);
+
+ rootScope.context['items'] = ['A', 'b'];
+ template(injector, element);
+
+ expect(element.text()).toEqual('');
+ // TODO(deboer): Digest twice until we have dirty checking in the scope.
+ rootScope.apply();
+ rootScope.apply();
+ expect(element.text()).toEqual('Ab');
+
+ rootScope.context['items'] = [];
+ rootScope.apply();
+ expect(element.html()).toEqual('<!--ANCHOR: [ng-repeat]=item in items-->');
+ }));
+
+ it('should compile repeater with children', inject((Compiler $compile) {
+ var element = $('<div><div ng-repeat="item in items"><div ng-bind="item"></div></div></div>');
+ var template = $compile(element, directives);
+
+ rootScope.context['items'] = ['A', 'b'];
+ template(injector, element);
+
+ expect(element.text()).toEqual('');
+ // TODO(deboer): Digest twice until we have dirty checking in the scope.
+ rootScope.apply();
+ rootScope.apply();
+ expect(element.text()).toEqual('Ab');
+
+ rootScope.context['items'] = [];
+ rootScope.apply();
+ expect(element.html()).toEqual('<!--ANCHOR: [ng-repeat]=item in items-->');
+ }));
+
+ it('should compile text', inject((Compiler $compile) {
+ var element = $('<div>{{name}}<span>!</span></div>').contents();
+ element.remove(null);
+
+ var template = $compile(element, directives);
+
+ rootScope.context['name'] = 'OK';
+ var block = template(injector, element);
+
+ element = $(block.elements);
+
+ rootScope.apply();
+ expect(element.text()).toEqual('OK!');
+ }));
+
+ it('should compile nested repeater', inject((Compiler $compile) {
+ var element = $(
'<div>' +
- '<ul ng-repeat="lis in uls">' +
- '<li ng-repeat="li in lis">{{li}}</li>' +
- '</ul>' +
+ '<ul ng-repeat="lis in uls">' +
+ '<li ng-repeat="li in lis">{{li}}</li>' +
+ '</ul>' +
'</div>');
+ var template = $compile(element, directives);
- _.rootScope.context['uls'] = [['A'], ['b']];
+ rootScope.context['uls'] = [['A'], ['b']];
+ template(injector, element);
- _.rootScope.apply();
- expect(element.text).toEqual('Ab');
- });
+ rootScope.apply();
+ expect(element.text()).toEqual('Ab');
+ }));
- it('should compile two directives with the same selector', (Logger log) {
- var element = _.compile('<div two-directives></div>');
+ it('should compile two directives with the same selector', inject((Logger log) {
+ var element = $('<div two-directives></div>');
+ var template = $compile(element, directives);
- _.rootScope.apply();
+ template(injector, element);
+ rootScope.apply();
expect(log).toEqual(['OneOfTwo', 'TwoOfTwo']);
- });
+ }));
- it('should compile a directive that ignores children', (Logger log) {
- // The ng-repeat comes first, so it is not ignored, but the children *are*
- var element = _.compile('<div ng-repeat="i in [1,2]" ignore-children><div two-directives></div></div>');
-
- _.rootScope.apply();
-
- expect(log).toEqual(['Ignore', 'Ignore']);
- });
-
- it('should compile a text child after a directive child', () {
- _.compile('<div><span ng-show="true">hi</span>{{hello}}</div>');
- });
describe("interpolation", () {
- it('should interpolate attribute nodes', () {
- var element = _.compile('<div test="{{name}}"></div>');
+ it('should interpolate attribute nodes', inject(() {
+ var element = $('<div test="{{name}}"></div>');
+ var template = $compile(element, directives);
- _.rootScope.context['name'] = 'angular';
+ rootScope.context['name'] = 'angular';
+ template(injector, element);
- _.rootScope.apply();
- expect(element.attributes['test']).toEqual('angular');
- });
+ rootScope.apply();
+ expect(element.attr('test')).toEqual('angular');
+ }));
- it('should interpolate text nodes', () {
- var element = _.compile('<div>{{name}}</div>');
+ it('should interpolate text nodes', inject(() {
+ var element = $('<div>{{name}}</div>');
+ var template = $compile(element, directives);
- _.rootScope.context['name'] = 'angular';
+ rootScope.context['name'] = 'angular';
+ template(injector, element);
- _.rootScope.apply();
- expect(element.text).toEqual('angular');
- });
+ rootScope.apply();
+ expect(element.text()).toEqual('angular');
+ }));
});
describe('components', () {
- beforeEachModule((Module module) {
- module
- ..type(CamelCaseMapComponent)
- ..type(IoComponent)
- ..type(IoControllerComponent)
- ..type(UnpublishedIoControllerComponent)
- ..type(IncorrectMappingComponent)
- ..type(NonAssignableMappingComponent)
- ..type(ParentExpressionComponent)
- ..type(PublishMeComponent)
- ..type(PublishMeDirective)
- ..type(LogComponent)
- ..type(AttachDetachComponent)
- ..type(SimpleAttachComponent)
- ..type(SimpleComponent)
- ..type(SometimesComponent)
- ..type(ExprAttrComponent)
- ..type(LogElementComponent)
- ..type(SayHelloFilter);
- });
-
- it('should select on element', async(() {
- var element = _.compile(r'<div><simple></simple></div>');
- microLeap();
- _.rootScope.apply();
- expect(element).toHaveText('INNER()');
+ beforeEach(module((Module module) {
+ module.type(SimpleComponent);
+ module.type(CamelCaseMapComponent);
+ module.type(IoComponent);
+ module.type(IoControllerComponent);
+ module.type(UnpublishedIoControllerComponent);
+ module.type(IncorrectMappingComponent);
+ module.type(NonAssignableMappingComponent);
+ module.type(ParentExpressionComponent);
+ module.type(PublishMeComponent);
+ module.type(PublishMeDirective);
+ module.type(LogComponent);
+ module.type(AttachDetachComponent);
+ module.type(SimpleAttachComponent);
+ module.type(SimpleComponent);
+ module.type(ExprAttrComponent);
+ module.type(SayHelloFilter);
}));
- it('should tranclude correctly', async(() {
- var element = _.compile(r'<div><simple>trans</simple></div>');
- microLeap();
- _.rootScope.apply();
- expect(element).toHaveText('INNER(trans)');
- }));
+ it('should select on element', async(inject((NgZone zone) {
+ var element = $(r'<div><simple></simple></div>');
- it('should tranclude if content was not present initially', async(() {
- var element = _.compile(r'<div>And <sometimes sometimes=sometimes>jump</sometimes></div>');
- document.body.append(element);
- microLeap();
- _.rootScope.apply();
- expect(element).toHaveText('And ');
-
- _.rootScope.context['sometimes'] = true;
- microLeap();
- _.rootScope.apply();
- expect(element).toHaveText('And jump');
- }));
-
- it('should redistribute content when the content tag disappears', async(() {
- var element = _.compile(r'<div>And <sometimes sometimes=sometimes>jump</sometimes></div>');
- document.body.append(element);
+ zone.run(() {
+ BlockFactory blockFactory = $compile(element, directives);
+ Block block = blockFactory(injector, element);
+ });
- _.rootScope.context['sometimes'] = true;
microLeap();
- _.rootScope.apply();
- expect(element).toHaveText('And jump');
+ expect(element.textWithShadow()).toEqual('INNER()');
+ })));
- _.rootScope.context['sometimes'] = false;
- microLeap();
- _.rootScope.apply();
- expect(element).toHaveText('And ');
+ it('should create a simple component', async(inject((NgZone zone) {
+ rootScope.context['name'] = 'OUTTER';
+ var element = $(r'<div>{{name}}:<simple>{{name}}</simple></div>');
- _.rootScope.context['sometimes'] = true;
- microLeap();
- _.rootScope.apply();
- expect(element).toHaveText('And jump');
- }));
+ zone.run(() {
+ BlockFactory blockFactory = $compile(element, directives);
+ Block block = blockFactory(injector, element);
+ });
- it('should store ElementProbe with Elements', async(() {
- _.compile('<div><simple>innerText</simple></div>');
microLeap();
- _.rootScope.apply();
- var simpleElement = _.rootElement.querySelector('simple');
- expect(simpleElement).toHaveText('INNER(innerText)');
- var simpleProbe = ngProbe(simpleElement);
- var simpleComponent = simpleProbe.injector.get(SimpleComponent);
- expect(simpleComponent.scope.context['name']).toEqual('INNER');
- var shadowRoot = simpleElement.shadowRoot;
-
- // If there is no shadow root, skip this.
- if (shadowRoot != null) {
- var shadowProbe = ngProbe(shadowRoot);
- expect(shadowProbe).toBeNotNull();
- expect(shadowProbe.element).toEqual(shadowRoot);
- expect(shadowProbe.parent.element).toEqual(simpleElement);
- }
- }));
+ expect(element.textWithShadow()).toEqual('OUTTER:INNER(OUTTER)');
+ })));
- it('should create a simple component', async((VmTurnZone zone) {
- _.rootScope.context['name'] = 'OUTTER';
- var element = _.compile(r'<div>{{name}}:<simple>{{name}}</simple></div>');
- microLeap();
- _.rootScope.apply();
- expect(element).toHaveText('OUTTER:INNER(OUTTER)');
- }));
+ it('should create a component that can access parent scope', async(inject((NgZone zone) {
+ rootScope.context['fromParent'] = "should not be used";
+ rootScope.context['val'] = "poof";
+ var element = $('<parent-expression from-parent=val></parent-expression>');
- it('should create a component that can access parent scope', async((VmTurnZone zone) {
- _.rootScope.context['fromParent'] = "should not be used";
- _.rootScope.context['val'] = "poof";
- var element = _.compile('<parent-expression from-parent=val></parent-expression>');
+ zone.run(() =>
+ $compile(element, directives)(injector, element));
microLeap();
- _.rootScope.apply();
- expect(element).toHaveText('inside poof');
- }));
+ expect(renderedText(element)).toEqual('inside poof');
+ })));
- it('should behave nicely if a mapped attribute is missing', async((VmTurnZone zone) {
- var element = _.compile('<parent-expression></parent-expression>');
+ it('should behave nicely if a mapped attribute is missing', async(inject((NgZone zone) {
+ var element = $('<parent-expression></parent-expression>');
+ zone.run(() =>
+ $compile(element, directives)(injector, element));
microLeap();
- _.rootScope.apply();
- expect(element).toHaveText('inside ');
- }));
+ expect(renderedText(element)).toEqual('inside ');
+ })));
- it('should behave nicely if a mapped attribute evals to null', async((VmTurnZone zone) {
- _.rootScope.context['val'] = null;
- var element = _.compile('<parent-expression fromParent=val></parent-expression>');
+ it('should behave nicely if a mapped attribute evals to null', async(inject((NgZone zone) {
+ rootScope.context['val'] = null;
+ var element = $('<parent-expression fromParent=val></parent-expression>');
+ zone.run(() =>
+ $compile(element, directives)(injector, element));
microLeap();
- _.rootScope.apply();
- expect(element).toHaveText('inside ');
- }));
+ expect(renderedText(element)).toEqual('inside ');
+ })));
- it('should create a component with I/O', async(() {
- _.compile(r'<div><io attr="A" expr="name" ondone="done=true"></io></div>');
+ it('should create a component with I/O', async(inject(() {
+ var element = $(r'<div><io attr="A" expr="name" ondone="done=true"></io></div>');
+ $compile(element, directives)(injector, element);
microLeap();
- _.rootScope.context['name'] = 'misko';
- _.rootScope.apply();
- var component = _.rootScope.context['ioComponent'];
+ rootScope.context['name'] = 'misko';
+ rootScope.apply();
+ var component = rootScope.context['ioComponent'];
expect(component.scope.context['name']).toEqual(null);
expect(component.scope.context['attr']).toEqual('A');
expect(component.scope.context['expr']).toEqual('misko');
component.scope.context['expr'] = 'angular';
- _.rootScope.apply();
- expect(_.rootScope.context['name']).toEqual('angular');
- expect(_.rootScope.context['done']).toEqual(null);
+ rootScope.apply();
+ expect(rootScope.context['name']).toEqual('angular');
+ expect(rootScope.context['done']).toEqual(null);
component.scope.context['ondone']();
- expect(_.rootScope.context['done']).toEqual(true);
- }));
+ expect(rootScope.context['done']).toEqual(true);
+ })));
- xit('should should not create any watchers if no attributes are specified', async((Profiler perf) {
- _.compile(r'<div><io></io></div>');
+ xit('should should not create any watchers if no attributes are specified', async(inject((Profiler perf) {
+ var element = $(r'<div><io></io></div>');
+ $compile(element, directives)(injector, element);
microLeap();
- _.injector.get(Scope).apply();
+ injector.get(Scope).apply();
// Re-enable once we can publish these numbers
- //expect(_.rootScope.watchGroup.totalFieldCost).toEqual(0);
- //expect(_.rootScope.watchGroup.totalCollectionCost).toEqual(0);
- //expect(_.rootScope.watchGroup.totalEvalCost).toEqual(0);
- //expect(_.rootScope.observeGroup.totalFieldCost).toEqual(0);
- //expect(_.rootScope.observeGroup.totalCollectionCost).toEqual(0);
- //expect(_.rootScope.observeGroup.totalEvalCost).toEqual(0);
- }));
-
- it('should create a component with I/O and "=" binding value should be available', async(() {
- _.rootScope.context['name'] = 'misko';
- _.compile(r'<div><io attr="A" expr="name" ondone="done=true"></io></div>');
+ //expect(rootScope.watchGroup.totalFieldCost).toEqual(0);
+ //expect(rootScope.watchGroup.totalCollectionCost).toEqual(0);
+ //expect(rootScope.watchGroup.totalEvalCost).toEqual(0);
+ //expect(rootScope.observeGroup.totalFieldCost).toEqual(0);
+ //expect(rootScope.observeGroup.totalCollectionCost).toEqual(0);
+ //expect(rootScope.observeGroup.totalEvalCost).toEqual(0);
+ })));
+
+ it('should create a component with I/O and "=" binding value should be available', async(inject(() {
+ rootScope.context['name'] = 'misko';
+ var element = $(r'<div><io attr="A" expr="name" ondone="done=true"></io></div>');
+ $compile(element, directives)(injector, element);
microLeap();
- var component = _.rootScope.context['ioComponent'];
- _.rootScope.apply();
+ var component = rootScope.context['ioComponent'];
+ rootScope.apply();
expect(component.scope.context['expr']).toEqual('misko');
component.scope.context['expr'] = 'angular';
- _.rootScope.apply();
- expect(_.rootScope.context['name']).toEqual('angular');
- }));
+ rootScope.apply();
+ expect(rootScope.context['name']).toEqual('angular');
+ })));
+
+ it('should create a component with I/O bound to controller and "=" binding value should be available', async(inject(() {
+ rootScope.context['done'] = false;
+ var element = $(r'<div><io-controller attr="A" expr="name" once="name" ondone="done=true"></io-controller></div>');
- it('should create a component with I/O bound to controller and "=" binding value should be available', async(() {
- _.rootScope.context['done'] = false;
- _.compile(r'<div><io-controller attr="A" expr="name" once="name" ondone="done=true"></io-controller></div>');
- expect(_.injector).toBeDefined();
+ expect(injector).toBeDefined();
+ $compile(element, directives)(injector, element);
microLeap();
- IoControllerComponent component = _.rootScope.context['ioComponent'];
+ IoControllerComponent component = rootScope.context['ioComponent'];
expect(component.expr).toEqual(null);
expect(component.exprOnce).toEqual(null);
expect(component.attr).toEqual('A');
- _.rootScope.apply();
+ rootScope.apply();
- _.rootScope.context['name'] = 'misko';
- _.rootScope.apply();
+ rootScope.context['name'] = 'misko';
+ rootScope.apply();
expect(component.expr).toEqual('misko');
expect(component.exprOnce).toEqual('misko');
- _.rootScope.context['name'] = 'igor';
- _.rootScope.apply();
+ rootScope.context['name'] = 'igor';
+ rootScope.apply();
expect(component.expr).toEqual('igor');
expect(component.exprOnce).toEqual('misko');
component.expr = 'angular';
- _.rootScope.apply();
- expect(_.rootScope.context['name']).toEqual('angular');
+ rootScope.apply();
+ expect(rootScope.context['name']).toEqual('angular');
- expect(_.rootScope.context['done']).toEqual(false);
+ expect(rootScope.context['done']).toEqual(false);
component.onDone();
- expect(_.rootScope.context['done']).toEqual(true);
+ expect(rootScope.context['done']).toEqual(true);
// Should be noop
component.onOptional();
- }));
+ })));
- it('should create a map attribute to controller', async(() {
- _.compile(r'<div><io-controller attr="{{name}}"></io-controller></div>');
+ it('should create a map attribute to controller', async(inject(() {
+ var element = $(r'<div><io-controller attr="{{name}}"></io-controller></div>');
+ $compile(element, directives)(injector, element);
microLeap();
- IoControllerComponent component = _.rootScope.context['ioComponent'];
+ IoControllerComponent component = rootScope.context['ioComponent'];
- _.rootScope.context['name'] = 'misko';
- _.rootScope.apply();
+ rootScope.context['name'] = 'misko';
+ rootScope.apply();
expect(component.attr).toEqual('misko');
- _.rootScope.context['name'] = 'james';
- _.rootScope.apply();
+ rootScope.context['name'] = 'james';
+ rootScope.apply();
expect(component.attr).toEqual('james');
- }));
+ })));
- it('should create a unpublished component with I/O bound to controller and "=" binding value should be available', async(() {
- _.rootScope.context['name'] = 'misko';
- _.rootScope.context['done'] = false;
- _.compile(r'<div><unpublished-io-controller attr="A" expr="name" ondone="done=true"></unpublished-io-controller></div>');
+ it('should create a unpublished component with I/O bound to controller and "=" binding value should be available', async(inject(() {
+ rootScope.context['name'] = 'misko';
+ rootScope.context['done'] = false;
+ var element = $(r'<div><unpublished-io-controller attr="A" expr="name" ondone="done=true"></unpublished-io-controller></div>');
+ $compile(element, directives)(injector, element);
microLeap();
- UnpublishedIoControllerComponent component = _.rootScope.context['ioComponent'];
- _.rootScope.apply();
+ UnpublishedIoControllerComponent component = rootScope.context['ioComponent'];
+ rootScope.apply();
expect(component.attr).toEqual('A');
expect(component.expr).toEqual('misko');
component.expr = 'angular';
- _.rootScope.apply();
- expect(_.rootScope.context['name']).toEqual('angular');
+ rootScope.apply();
+ expect(rootScope.context['name']).toEqual('angular');
- expect(_.rootScope.context['done']).toEqual(false);
+ expect(rootScope.context['done']).toEqual(false);
component.onDone();
- expect(_.rootScope.context['done']).toEqual(true);
+ expect(rootScope.context['done']).toEqual(true);
// Should be noop
component.onOptional();
- }));
+ })));
- it('should error on incorrect mapping', async(() {
+ it('should error on incorrect mapping', async(inject(() {
expect(() {
- _.compile(r'<div><incorrect-mapping></incorrect-mapping</div>');
+ var element = $(r'<div><incorrect-mapping></incorrect-mapping</div>');
+ $compile(element, directives)(injector, element);
}).toThrow("Unknown mapping 'foo\' for attribute 'attr'.");
- }));
+ })));
- it('should support formatters in attribute expressions', async(() {
- _.compile(r'''<expr-attr-component expr="'Misko' | hello" one-way="'James' | hello" once="'Chirayu' | hello"></expr-attr-component>''');
- ExprAttrComponent component = _.rootScope.context['exprAttrComponent'];
- _.rootScope.apply();
+ it('should support filters in attribute expressions', async(inject(() {
+ var element = $(r'''<expr-attr-component expr="'Misko' | hello" one-way="'James' | hello" once="'Chirayu' | hello"></expr-attr-component>''');
+ $compile(element, directives)(injector, element);
+ ExprAttrComponent component = rootScope.context['exprAttrComponent'];
+ rootScope.apply();
expect(component.expr).toEqual('Hello, Misko!');
expect(component.oneWay).toEqual('Hello, James!');
expect(component.exprOnce).toEqual('Hello, Chirayu!');
- }));
+ })));
- it('should error on non-asignable-mapping', async(() {
+ it('should error on non-asignable-mapping', async(inject(() {
expect(() {
- _.compile(r'<div><non-assignable-mapping></non-assignable-mapping</div>');
+ var element = $(r'<div><non-assignable-mapping></non-assignable-mapping</div>');
+ $compile(element, directives)(injector, element);
}).toThrow("Expression '1+2' is not assignable in mapping '@1+2' for attribute 'attr'.");
- }));
+ })));
- it('should expose mapped attributes as camel case', async(() {
- _.compile('<camel-case-map camel-case=G></camel-case-map>');
+ it('should expose mapped attributes as camel case', async(inject(() {
+ var element = $('<camel-case-map camel-case=G></camel-case-map>');
+ $compile(element, directives)(injector, element);
microLeap();
- _.rootScope.apply();
- var componentScope = _.rootScope.context['camelCase'];
+ rootScope.apply();
+ var componentScope = rootScope.context['camelCase'];
expect(componentScope.context['camelCase']).toEqual('G');
- }));
+ })));
- // TODO: This is a terrible test
- it('should throw an exception if required directive is missing', async(() {
+ it('should throw an exception if required directive is missing', async(inject((Compiler $compile, Scope rootScope, Injector injector) {
try {
- _.compile('<tab local><pane></pane><pane local></pane></tab>');
+ var element = $('<tab local><pane></pane><pane local></pane></tab>');
+ $compile(element, directives)(injector, element);
} catch (e) {
var text = '$e';
expect(text).toContain('No provider found for');
expect(text).toContain('(resolving ');
expect(text).toContain('LocalAttrDirective');
}
- }));
+ })));
+
+ it('should publish component controller into the scope', async(inject((NgZone zone) {
+ var element = $(r'<div><publish-me></publish-me></div>');
+ zone.run(() =>
+ $compile(element, directives)(injector, element));
- it('should publish component controller into the scope', async(() {
- var element = _.compile(r'<div><publish-me></publish-me></div>');
microLeap();
- _.rootScope.apply();
- expect(element).toHaveText('WORKED');
- }));
+ expect(element.textWithShadow()).toEqual('WORKED');
+ })));
- it('should publish directive controller into the scope', async((VmTurnZone zone) {
- var element = _.compile(r'<div><div publish-me>{{ctrlName.value}}</div></div>');
+ it('should publish directive controller into the scope', async(inject((NgZone zone) {
+ var element = $(r'<div><div publish-me>{{ctrlName.value}}</div></div>');
+ zone.run(() =>
+ $compile(element, directives)(injector, element));
microLeap();
- _.rootScope.apply();
- expect(element.text).toEqual('WORKED');
+ expect(element.text()).toEqual('WORKED');
+ })));
+
+ it('should "publish" controller to injector under provided publishTypes', inject(() {
+ var element = $(r'<div publish-types></div>');
+ $compile(element, directives)(injector, element);
+ expect(PublishTypesAttrDirective._injector.get(PublishTypesAttrDirective)).
+ toBe(PublishTypesAttrDirective._injector.get(PublishTypesDirectiveSuperType));
}));
- it('should "publish" controller to injector under provided module', () {
- _.compile(r'<div publish-types></div>');
- expect(PublishModuleAttrDirective._injector.get(PublishModuleAttrDirective)).
- toBe(PublishModuleAttrDirective._injector.get(PublishModuleDirectiveSuperType));
- });
-
- it('should allow repeaters over controllers', async((Logger logger) {
- _.compile(r'<log ng-repeat="i in [1, 2]"></log>');
- _.rootScope.apply();
+ it('should allow repeaters over controllers', async(inject((Logger logger) {
+ var element = $(r'<log ng-repeat="i in [1, 2]"></log>');
+ $compile(element, directives)(injector, element);
+ rootScope.apply();
microLeap();
expect(logger.length).toEqual(2);
- }));
+ })));
describe('lifecycle', () {
- beforeEachModule((Module module) {
- var httpBackend = new MockHttpBackend();
-
+ var backend;
+ beforeEach(module((Module module) {
+ backend = new MockHttpBackend();
module
- ..value(HttpBackend, httpBackend)
- ..value(MockHttpBackend, httpBackend);
- });
+ ..value(HttpBackend, backend)
+ ..value(MockHttpBackend, backend);
+ }));
- it('should fire onShadowRoot method', async((Compiler compile, Logger logger, MockHttpBackend backend) {
- backend.whenGET('some/template.url').respond(200, '<div>WORKED</div>');
- var scope = _.rootScope.createChild({});
+ it('should fire onTemplate method', async(inject((Logger logger, MockHttpBackend backend) {
+ backend.whenGET('some/template.url').respond('<div>WORKED</div>');
+ var scope = rootScope.createChild({});
scope.context['isReady'] = 'ready';
scope.context['logger'] = logger;
scope.context['once'] = null;
- var elts = es('<attach-detach attr-value="{{isReady}}" expr-value="isReady" once-value="once">{{logger("inner")}}</attach-detach>');
- compile(elts, _.injector.get(DirectiveMap))(_.injector.createChild([new Module()..value(Scope, scope)]), elts);
+ var element = $('<attach-detach attr-value="{{isReady}}" expr-value="isReady" once-value="once">{{logger("inner")}}</attach-detach>');
+ $compile(element, directives)(injector.createChild([new Module()..value(Scope, scope)]), element);
expect(logger).toEqual(['new']);
expect(logger).toEqual(['new']);
- _.rootScope.apply();
+ rootScope.apply();
var expected = ['new', 'attach:@ready; =>ready; =>!null', 'inner'];
assert((() {
// there is an assertion in flush which double checks that
@@ -558,180 +476,119 @@ void main() {
expect(logger).toEqual(expected);
logger.clear();
- microLeap();
backend.flush();
microLeap();
- expect(logger).toEqual(['templateLoaded', _.rootScope.context['shadowRoot']]);
+ expect(logger).toEqual(['templateLoaded', rootScope.context['shadowRoot']]);
logger.clear();
scope.destroy();
expect(logger).toEqual(['detach']);
- expect(elts).toHaveText('WORKED');
- }));
+ expect(element.textWithShadow()).toEqual('WORKED');
+ })));
- it('should should not call attach after scope is destroyed', async((Compiler compile, Logger logger, MockHttpBackend backend) {
+ it('should should not call attach after scope is destroyed', async(inject((Logger logger, MockHttpBackend backend) {
backend.whenGET('foo.html').respond('<div>WORKED</div>');
- var elts = es('<simple-attach></simple-attach>');
- var scope = _.rootScope.createChild({});
- compile(elts, _.injector.get(DirectiveMap))(_.injector.createChild([new Module()..value(Scope, scope)]), elts);
+ var element = $('<simple-attach></simple-attach>');
+ var scope = rootScope.createChild({});
+ $compile(element, directives)(injector.createChild([new Module()..value(Scope, scope)]), element);
expect(logger).toEqual(['SimpleAttachComponent']);
scope.destroy();
- _.rootScope.apply();
+ rootScope.apply();
microLeap();
expect(logger).toEqual(['SimpleAttachComponent']);
- }));
-
- it('should inject compenent element as the dom.Element', async((Logger log, TestBed _, MockHttpBackend backend) {
- backend.whenGET('foo.html').respond('<div>WORKED</div>');
- _.compile('<log-element></log-element>');
- Element element = _.rootElement;
- expect(log).toEqual([element, element,
- // If we don't have a shadowRoot, this is an invalid check
- element.shadowRoot != null ? element.shadowRoot : log[2]]);
- }));
+ })));
});
describe('invalid components', () {
it('should throw a useful error message for missing selectors', () {
- Module module = new Module()
+ module((Module module) {
+ module
..type(MissingSelector);
- var injector = _.injector.createChild([module], forceNewInstances: [Compiler, DirectiveMap]);
- var c = injector.get(Compiler);
- var directives = injector.get(DirectiveMap);
+ });
expect(() {
- c(es('<div></div>'), injector.get(DirectiveMap));
+ inject((Compiler c) { });
}).toThrow('Missing selector annotation for MissingSelector');
});
it('should throw a useful error message for invalid selector', () {
- Module module = new Module()
- ..type(InvalidSelector);
- var injector = _.injector.createChild([module], forceNewInstances: [Compiler, DirectiveMap]);
- var c = injector.get(Compiler);
- var directives = injector.get(DirectiveMap);
-
+ module((Module module) {
+ module
+ ..type(InvalidSelector);
+ });
expect(() {
- c(es('<div></div>'), directives);
+ inject((Compiler c) { });
}).toThrow('Unknown selector format \'buttonbar button\' for InvalidSelector');
});
});
-
- describe('useShadowDom option', () {
- beforeEachModule((Module m) {
- m.type(ShadowyComponent);
- m.type(ShadowlessComponent);
- });
-
- it('should create shadowy components', async((Logger log) {
- _.compile('<shadowy></shadowy>');
- expect(log).toEqual(['shadowy']);
- expect(_.rootElement.shadowRoot).toBeNotNull();
- }));
-
- it('should create shadowless components', async((Logger log) {
- _.compile('<shadowless></shadowless>');
- expect(log).toEqual(['shadowless']);
- expect(_.rootElement.shadowRoot).toBeNull();
- }));
-
- it('should create other components with the default strategy', async((ComponentFactory factory) {
- _.compile('<simple></simple>');
- if (factory is TranscludingComponentFactory) {
- expect(_.rootElement.shadowRoot).toBeNull();
- } else {
- expect(factory is ShadowDomComponentFactory).toBeTruthy();
- expect(_.rootElement.shadowRoot).toBeNotNull();
- }
- }));
- });
});
describe('controller scoping', () {
- it('should make controllers available to sibling and child controllers', async((Logger log) {
- _.compile('<tab local><pane local></pane><pane local></pane></tab>');
+ it('should make controllers available to sibling and child controllers', async(inject((Compiler $compile, Scope rootScope, Logger log, Injector injector) {
+ var element = $('<tab local><pane local></pane><pane local></pane></tab>');
+ $compile(element, directives)(injector, element);
microLeap();
expect(log.result()).toEqual('TabComponent-0; LocalAttrDirective-0; PaneComponent-1; LocalAttrDirective-0; PaneComponent-2; LocalAttrDirective-0');
- }));
-
- it('should use the correct parent injector', async((Logger log) {
- // Getting the parent offsets correct while descending the template is tricky. If we get it wrong, this
- // test case will create too many TabComponents.
+ })));
- _.compile('<div ng-bind="true"><div ignore-children></div><tab local><pane local></pane></tab>');
+ it('should reuse controllers for transclusions', async(inject((Compiler $compile, Scope rootScope, Logger log, Injector injector) {
+ var element = $('<div simple-transclude-in-attach include-transclude>block</div>');
+ $compile(element, directives)(injector, element);
microLeap();
- expect(log.result()).toEqual('Ignore; TabComponent-0; LocalAttrDirective-0; PaneComponent-1; LocalAttrDirective-0');
- }));
-
- it('should reuse controllers for transclusions', async((Logger log) {
- _.compile('<div simple-transclude-in-attach include-transclude>view</div>');
- microLeap();
-
- _.rootScope.apply();
+ rootScope.apply();
expect(log.result()).toEqual('IncludeTransclude; SimpleTransclude');
- }));
+ })));
- it('should expose a parent controller to the scope of its children', (TestBed _) {
- var element = _.compile('<div my-parent-controller>'
- ' <div my-child-controller>{{ my_parent.data() }}</div>'
- '</div>');
+ it('should expose a parent controller to the scope of its children', inject((TestBed _) {
- _.rootScope.apply();
-
- expect(element.text).toContain('my data');
- });
+ var element = _.compile('<div my-parent-controller>' +
+ ' <div my-child-controller>{{ my_parent.data() }}</div>' +
+ '</div>');
- it('should expose a ancestor controller to the scope of its children thru a undecorated element', (TestBed _) {
- var element = _.compile(
- '<div my-parent-controller>'
- '<div>'
- '<div my-child-controller>{{ my_parent.data() }}</div>'
- '</div>'
- '</div>');
-
- _.rootScope.apply();
+ rootScope.apply();
expect(element.text).toContain('my data');
- });
+ }));
});
- describe('Decorator', () {
- it('should allow creation of a new scope', () {
+ describe('NgDirective', () {
+ it('should allow creation of a new scope', inject((TestBed _) {
_.rootScope.context['name'] = 'cover me';
_.compile('<div><div my-controller>{{name}}</div></div>');
_.rootScope.apply();
expect(_.rootScope.context['name']).toEqual('cover me');
expect(_.rootElement.text).toEqual('MyController');
- });
+ }));
});
- }));
-}
+ });
-@Controller(
+@NgController(
selector: '[my-parent-controller]',
- publishAs: 'my_parent')
+ publishAs: 'my_parent'
+)
class MyParentController {
data() {
return "my data";
}
}
-@Controller(
+@NgController(
selector: '[my-child-controller]',
- publishAs: 'my_child')
+ publishAs: 'my_child'
+)
class MyChildController {}
-@Component(
+@NgComponent(
selector: 'tab',
- visibility: Directive.DIRECT_CHILDREN_VISIBILITY)
+ visibility: NgDirective.DIRECT_CHILDREN_VISIBILITY)
class TabComponent {
int id = 0;
Logger log;
@@ -742,7 +599,7 @@ class TabComponent {
}
}
-@Component(selector: 'pane')
+@NgComponent(selector: 'pane')
class PaneComponent {
TabComponent tabComponent;
LocalAttrDirective localDirective;
@@ -753,9 +610,9 @@ class PaneComponent {
}
}
-@Decorator(
+@NgDirective(
selector: '[local]',
- visibility: Directive.LOCAL_VISIBILITY)
+ visibility: NgDirective.LOCAL_VISIBILITY)
class LocalAttrDirective {
int id = 0;
Logger log;
@@ -765,116 +622,72 @@ class LocalAttrDirective {
}
}
-@Decorator(
+@NgDirective(
selector: '[simple-transclude-in-attach]',
- visibility: Directive.CHILDREN_VISIBILITY, children: Directive.TRANSCLUDE_CHILDREN)
+ visibility: NgDirective.CHILDREN_VISIBILITY, children: NgAnnotation.TRANSCLUDE_CHILDREN)
class SimpleTranscludeInAttachAttrDirective {
- SimpleTranscludeInAttachAttrDirective(ViewPort viewPort, BoundViewFactory boundViewFactory, Logger log, RootScope scope) {
+ SimpleTranscludeInAttachAttrDirective(BlockHole blockHole, BoundBlockFactory boundBlockFactory, Logger log, RootScope scope) {
scope.runAsync(() {
- var view = boundViewFactory(scope);
- viewPort.insert(view);
+ var block = boundBlockFactory(scope);
+ block.insertAfter(blockHole);
log('SimpleTransclude');
});
}
}
-@Decorator(selector: '[include-transclude]')
+@NgDirective(selector: '[include-transclude]')
class IncludeTranscludeAttrDirective {
IncludeTranscludeAttrDirective(SimpleTranscludeInAttachAttrDirective simple, Logger log) {
log('IncludeTransclude');
}
}
-@Decorator(selector: '[two-directives]')
+@NgDirective(selector: '[two-directives]')
class OneOfTwoDirectives {
OneOfTwoDirectives(Logger log) {
log('OneOfTwo');
}
}
-@Decorator(selector: '[two-directives]')
+@NgDirective(selector: '[two-directives]')
class TwoOfTwoDirectives {
TwoOfTwoDirectives(Logger log) {
log('TwoOfTwo');
}
}
-@Decorator(
- selector: '[ignore-children]',
- children: Directive.IGNORE_CHILDREN
-)
-class IgnoreChildrenDirective {
- IgnoreChildrenDirective(Logger log) {
- log('Ignore');
- }
+class PublishTypesDirectiveSuperType {
}
-class PublishModuleDirectiveSuperType {
-}
-
-@Decorator(
+@NgDirective(
selector: '[publish-types]',
- module: PublishModuleAttrDirective.module)
-class PublishModuleAttrDirective implements PublishModuleDirectiveSuperType {
- static Module _module = new Module()
- ..factory(PublishModuleDirectiveSuperType, (i) => i.get(PublishModuleAttrDirective));
- static module() => _module;
-
+ publishTypes: const [PublishTypesDirectiveSuperType])
+class PublishTypesAttrDirective implements PublishTypesDirectiveSuperType {
static Injector _injector;
- PublishModuleAttrDirective(Injector injector) {
+ PublishTypesAttrDirective(Injector injector) {
_injector = injector;
}
}
-@Component(
+@NgComponent(
selector: 'simple',
- template: r'{{name}}(<content>SHADOW-CONTENT</content>)')
+ template: r'{{name}}(<content>SHADOW-CONTENT</content>)'
+)
class SimpleComponent {
- Scope scope;
- SimpleComponent(Scope this.scope) {
+ SimpleComponent(Scope scope) {
scope.context['name'] = 'INNER';
}
}
-@Component(
- selector: 'shadowy',
- template: r'With shadow DOM',
- useShadowDom: true
-)
-class ShadowyComponent {
- ShadowyComponent(Logger log) {
- log('shadowy');
- }
-}
-
-@Component(
- selector: 'shadowless',
- template: r'Without shadow DOM',
- useShadowDom: false
-)
-class ShadowlessComponent {
- ShadowlessComponent(Logger log) {
- log('shadowless');
- }
-}
-
-@Component(
- selector: 'sometimes',
- template: r'<div ng-if="ctrl.sometimes"><content></content></div>',
- publishAs: 'ctrl')
-class SometimesComponent {
- @NgTwoWay('sometimes')
- var sometimes;
-}
-
-@Component(
+@NgComponent(
selector: 'io',
template: r'<content></content>',
map: const {
'attr': '@scope.context.attr',
'expr': '<=>scope.context.expr',
'ondone': '&scope.context.ondone',
- })
+ }
+)
class IoComponent {
Scope scope;
IoComponent(Scope scope) {
@@ -884,7 +697,7 @@ class IoComponent {
}
}
-@Component(
+@NgComponent(
selector: 'io-controller',
template: r'<content></content>',
publishAs: 'ctrl',
@@ -894,7 +707,8 @@ class IoComponent {
'once': '=>!exprOnce',
'ondone': '&onDone',
'on-optional': '&onOptional'
- })
+ }
+)
class IoControllerComponent {
Scope scope;
var attr;
@@ -908,7 +722,7 @@ class IoControllerComponent {
}
}
-@Component(
+@NgComponent(
selector: 'unpublished-io-controller',
template: r'<content></content>',
map: const {
@@ -916,7 +730,8 @@ class IoControllerComponent {
'expr': '<=>expr',
'ondone': '&onDone',
'onOptional': '&onOptional'
- })
+ }
+)
class UnpublishedIoControllerComponent {
Scope scope;
var attr;
@@ -930,23 +745,24 @@ class UnpublishedIoControllerComponent {
}
}
-@Component(
+@NgComponent(
selector: 'incorrect-mapping',
template: r'<content></content>',
map: const { 'attr': 'foo' })
class IncorrectMappingComponent { }
-@Component(
+@NgComponent(
selector: 'non-assignable-mapping',
template: r'<content></content>',
map: const { 'attr': '@1+2' })
class NonAssignableMappingComponent { }
-@Component(
+@NgComponent(
selector: 'camel-case-map',
map: const {
'camel-case': '@scope.context.camelCase',
- })
+ }
+)
class CamelCaseMapComponent {
Scope scope;
CamelCaseMapComponent(Scope this.scope) {
@@ -954,44 +770,49 @@ class CamelCaseMapComponent {
}
}
-@Component(
+@NgComponent(
selector: 'parent-expression',
template: '<div>inside {{fromParent()}}</div>',
map: const {
'from-parent': '&scope.context.fromParent',
- })
+ }
+)
class ParentExpressionComponent {
Scope scope;
ParentExpressionComponent(Scope this.scope);
}
-@Component(
+@NgComponent(
selector: 'publish-me',
- template: r'{{ctrlName.value}}',
- publishAs: 'ctrlName')
+ template: r'<content>{{ctrlName.value}}</content>',
+ publishAs: 'ctrlName'
+)
class PublishMeComponent {
String value = 'WORKED';
}
-@Controller (
+
+@NgController (
selector: '[publish-me]',
- publishAs: 'ctrlName')
+ publishAs: 'ctrlName'
+)
class PublishMeDirective {
String value = 'WORKED';
}
-@Component(
+@NgComponent(
selector: 'log',
template: r'<content></content>',
- publishAs: 'ctrlName')
+ publishAs: 'ctrlName'
+)
class LogComponent {
LogComponent(Scope scope, Logger logger) {
logger(scope);
}
}
-@Component(
+@NgComponent(
selector: 'attach-detach',
templateUrl: 'some/template.url',
map: const {
@@ -1001,8 +822,9 @@ class LogComponent {
'optional-one': '=>optional',
'optional-two': '<=>optional',
'optional-once': '=>!optional',
- })
-class AttachDetachComponent implements AttachAware, DetachAware, ShadowRootAware {
+ }
+)
+class AttachDetachComponent implements NgAttachAware, NgDetachAware, NgShadowRootAware {
Logger logger;
Scope scope;
String attrValue = 'too early';
@@ -1023,29 +845,30 @@ class AttachDetachComponent implements AttachAware, DetachAware, ShadowRootAware
}
}
-@Controller(
+@NgController(
selector: '[my-controller]',
- publishAs: 'myCtrl')
+ publishAs: 'myCtrl'
+)
class MyController {
MyController(Scope scope) {
scope.context['name'] = 'MyController';
}
}
-@Component()
+@NgComponent()
class MissingSelector {}
-@Component(selector: 'buttonbar button')
+@NgComponent(selector: 'buttonbar button')
class InvalidSelector {}
-@Formatter(name:'hello')
+@NgFilter(name:'hello')
class SayHelloFilter {
call(String str) {
return 'Hello, $str!';
}
}
-@Component(
+@NgComponent(
selector: 'expr-attr-component',
template: r'<content></content>',
publishAs: 'ctrl',
@@ -1053,7 +876,8 @@ class SayHelloFilter {
'expr': '<=>expr',
'one-way': '=>oneWay',
'once': '=>!exprOnce'
- })
+ }
+)
class ExprAttrComponent {
var expr;
var oneWay;
@@ -1064,10 +888,10 @@ class ExprAttrComponent {
}
}
-@Component(
+@NgComponent(
selector: 'simple-attach',
templateUrl: 'foo.html')
-class SimpleAttachComponent implements AttachAware, ShadowRootAware {
+class SimpleAttachComponent implements NgAttachAware, NgShadowRootAware {
Logger logger;
SimpleAttachComponent(this.logger) {
logger('SimpleAttachComponent');
@@ -1075,15 +899,3 @@ class SimpleAttachComponent implements AttachAware, ShadowRootAware {
attach() => logger('attach');
onShadowRoot(_) => logger('onShadowRoot');
}
-
-@Component(
- selector: 'log-element',
- templateUrl: 'foo.html')
-class LogElementComponent{
- LogElementComponent(Logger logger, Element element, Node node,
- ShadowRoot shadowRoot) {
- logger(element);
- logger(node);
- logger(shadowRoot);
- }
-}
« no previous file with comments | « third_party/pkg/angular/test/core_dom/block_spec.dart ('k') | third_party/pkg/angular/test/core_dom/cookies_spec.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698