Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 775bbce

Browse files
pavelgjmhevery
authored andcommitted
fix(ng-repeat): should correctly handle detached state
Closes #697
1 parent 9354924 commit 775bbce

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

test/directive/ng_repeat_spec.dart

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ main() {
99
beforeEach(inject((Injector injector, Scope $rootScope, Compiler compiler, DirectiveMap _directives) {
1010
$exceptionHandler = injector.get(ExceptionHandler);
1111
scope = $rootScope;
12-
$compile = (html) {
12+
$compile = (html, [scope]) {
1313
element = $(html);
1414
var viewFactory = compiler(element, _directives);
15-
var view = viewFactory(injector, element);
15+
var blockInjector = injector;
16+
if (scope != null) {
17+
viewFactory.bind(injector)(scope);
18+
} else {
19+
viewFactory(injector, element);
20+
}
1621
return element;
1722
};
1823
directives = _directives;
@@ -404,5 +409,19 @@ main() {
404409
});
405410
});
406411

412+
413+
it('should correctly handle detached state', () {
414+
scope.context['items'] = [1];
415+
416+
var parentScope = scope.createChild(new PrototypeMap(scope.context));
417+
element = $compile(
418+
'<ul>' +
419+
'<li ng-repeat="item in items">{{item}}</li>' +
420+
'</ul>', parentScope);
421+
422+
parentScope.destroy();
423+
expect(scope.apply).not.toThrow();
424+
});
425+
407426
});
408427
}

0 commit comments

Comments
 (0)