diff --git a/lib/change_detection/watch_group.dart b/lib/change_detection/watch_group.dart index 65866e497..3c1976534 100644 --- a/lib/change_detection/watch_group.dart +++ b/lib/change_detection/watch_group.dart @@ -413,7 +413,6 @@ class RootWatchGroup extends WatchGroup { Watch dirtyWatch = _dirtyWatchHead; _dirtyWatchHead = null; RootWatchGroup root = _rootGroup; - root._removeCount = 0; try { while(dirtyWatch != null) { count++; @@ -430,6 +429,7 @@ class RootWatchGroup extends WatchGroup { } } finally { _dirtyWatchTail = null; + root._removeCount = 0; } if (processStopwatch != null) processStopwatch..stop()..increment(count); return count; diff --git a/test/core/scope_spec.dart b/test/core/scope_spec.dart index 6d1cc484f..00c217a9b 100644 --- a/test/core/scope_spec.dart +++ b/test/core/scope_spec.dart @@ -740,6 +740,18 @@ void main() { rootScope.apply(); expect(log).toEqual(['root destroy', 'root2 destroy']); })); + + + it('should not call reaction fn when destroyed', inject((RootScope scope) { + var testScope = scope.createChild({}); + bool called = false; + testScope.watch('items', (_, __) { + called = true; + }); + testScope.destroy(); + scope.apply(); + expect(called).toBeFalsy(); + })); });