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

Commit 0aacdc4

Browse files
committed
fix(chonge-detection): don't call reactionFn on deleted scope
1 parent 1ba5bef commit 0aacdc4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/change_detection/watch_group.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,6 @@ class RootWatchGroup extends WatchGroup {
413413
Watch dirtyWatch = _dirtyWatchHead;
414414
_dirtyWatchHead = null;
415415
RootWatchGroup root = _rootGroup;
416-
root._removeCount = 0;
417416
try {
418417
while(dirtyWatch != null) {
419418
count++;
@@ -430,6 +429,7 @@ class RootWatchGroup extends WatchGroup {
430429
}
431430
} finally {
432431
_dirtyWatchTail = null;
432+
root._removeCount = 0;
433433
}
434434
if (processStopwatch != null) processStopwatch..stop()..increment(count);
435435
return count;

test/core/scope_spec.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,18 @@ void main() {
740740
rootScope.apply();
741741
expect(log).toEqual(['root destroy', 'root2 destroy']);
742742
}));
743+
744+
745+
it('should not call reaction fn when destroyed', inject((RootScope scope) {
746+
var testScope = scope.createChild({});
747+
bool called = false;
748+
testScope.watch('items', (_, __) {
749+
called = true;
750+
});
751+
testScope.destroy();
752+
scope.apply();
753+
expect(called).toBeFalsy();
754+
}));
743755
});
744756

745757

0 commit comments

Comments
 (0)