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

Commit

Permalink
fix(chonge-detection): don't call reactionFn on deleted scope
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery committed Mar 11, 2014
1 parent 1ba5bef commit 0aacdc4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/change_detection/watch_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ class RootWatchGroup extends WatchGroup {
Watch dirtyWatch = _dirtyWatchHead;
_dirtyWatchHead = null;
RootWatchGroup root = _rootGroup;
root._removeCount = 0;
try {
while(dirtyWatch != null) {
count++;
Expand All @@ -430,6 +429,7 @@ class RootWatchGroup extends WatchGroup {
}
} finally {
_dirtyWatchTail = null;
root._removeCount = 0;
}
if (processStopwatch != null) processStopwatch..stop()..increment(count);
return count;
Expand Down
12 changes: 12 additions & 0 deletions test/core/scope_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}));
});


Expand Down

0 comments on commit 0aacdc4

Please sign in to comment.