From 775bbce4060c3828c1cbaeffcb8fc4092f46868b Mon Sep 17 00:00:00 2001 From: Pavel Jbanov Date: Mon, 10 Mar 2014 15:59:53 -0400 Subject: [PATCH] fix(ng-repeat): should correctly handle detached state Closes #697 --- test/directive/ng_repeat_spec.dart | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/test/directive/ng_repeat_spec.dart b/test/directive/ng_repeat_spec.dart index a3e6f8d34..cddc9d93e 100644 --- a/test/directive/ng_repeat_spec.dart +++ b/test/directive/ng_repeat_spec.dart @@ -9,10 +9,15 @@ main() { beforeEach(inject((Injector injector, Scope $rootScope, Compiler compiler, DirectiveMap _directives) { $exceptionHandler = injector.get(ExceptionHandler); scope = $rootScope; - $compile = (html) { + $compile = (html, [scope]) { element = $(html); var viewFactory = compiler(element, _directives); - var view = viewFactory(injector, element); + var blockInjector = injector; + if (scope != null) { + viewFactory.bind(injector)(scope); + } else { + viewFactory(injector, element); + } return element; }; directives = _directives; @@ -404,5 +409,19 @@ main() { }); }); + + it('should correctly handle detached state', () { + scope.context['items'] = [1]; + + var parentScope = scope.createChild(new PrototypeMap(scope.context)); + element = $compile( + '', parentScope); + + parentScope.destroy(); + expect(scope.apply).not.toThrow(); + }); + }); }