| Index: third_party/pkg/angular/lib/mock/test_bed.dart
|
| diff --git a/third_party/pkg/angular/lib/mock/test_bed.dart b/third_party/pkg/angular/lib/mock/test_bed.dart
|
| index af5882cc34f59984d8b0621f5b5ab24292edaa57..ac1b5ddc8e653fddaa887a5a66272460a72ecc35 100644
|
| --- a/third_party/pkg/angular/lib/mock/test_bed.dart
|
| +++ b/third_party/pkg/angular/lib/mock/test_bed.dart
|
| @@ -34,9 +34,9 @@ class TestBed {
|
| *
|
| * An option [scope] parameter can be supplied to link it with non root scope.
|
| */
|
| - Element compile(html, {Scope scope}) {
|
| + Element compile(html, {Scope scope, DirectiveMap directives}) {
|
| var injector = this.injector;
|
| - if(scope != null) {
|
| + if (scope != null) {
|
| injector = injector.createChild([new Module()..value(Scope, scope)]);
|
| }
|
| if (html is String) {
|
| @@ -49,7 +49,10 @@ class TestBed {
|
| throw 'Expecting: String, Node, or List<Node> got $html.';
|
| }
|
| rootElement = rootElements[0];
|
| - rootBlock = compiler(rootElements)(injector, rootElements);
|
| + if (directives == null) {
|
| + directives = injector.get(DirectiveMap);
|
| + }
|
| + rootBlock = compiler(rootElements, directives)(injector, rootElements);
|
| return rootElement;
|
| }
|
|
|
| @@ -60,7 +63,7 @@ class TestBed {
|
| var div = new DivElement();
|
| div.setInnerHtml(html, treeSanitizer: new NullTreeSanitizer());
|
| var nodes = [];
|
| - for(var node in div.nodes) {
|
| + for (var node in div.nodes) {
|
| nodes.add(node);
|
| }
|
| return nodes;
|
| @@ -72,6 +75,8 @@ class TestBed {
|
| */
|
| triggerEvent(element, name, [type='MouseEvent']) {
|
| element.dispatchEvent(new Event.eventType(type, name));
|
| + // Since we are manually triggering event we need to simpulate apply();
|
| + rootScope.apply();
|
| }
|
|
|
| /**
|
| @@ -81,5 +86,6 @@ class TestBed {
|
| selectOption(element, text) {
|
| element.querySelectorAll('option').forEach((o) => o.selected = o.text == text);
|
| triggerEvent(element, 'change');
|
| + rootScope.apply();
|
| }
|
| }
|
|
|