Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 02c0469

Browse files
dchermangkalpak
authored andcommitted
fix($rootScope): don't allow explicit digest calls to affect $evalAsync
Fixes #15127 Closes #15494
1 parent c3d5cc5 commit 02c0469

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/ng/rootScope.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ function $RootScopeProvider() {
772772
var watch, value, last, fn, get,
773773
watchers,
774774
dirty, ttl = TTL,
775-
next, current, target = this,
775+
next, current, target = asyncQueue.length ? $rootScope : this,
776776
watchLog = [],
777777
logIdx, asyncTask;
778778

test/ng/rootScopeSpec.js

+19
Original file line numberDiff line numberDiff line change
@@ -2142,6 +2142,25 @@ describe('Scope', function() {
21422142
$browser.defer.flush(100000);
21432143
expect(log).toEqual(['eval-ed 1!', 'eval-ed 2!']);
21442144
});
2145+
2146+
it('should not have execution affected by an explicit $digest call', function() {
2147+
var scope1 = $rootScope.$new();
2148+
var scope2 = $rootScope.$new();
2149+
2150+
scope1.$watch('value', function(value) {
2151+
scope1.result = value;
2152+
});
2153+
2154+
scope1.$evalAsync(function() {
2155+
scope1.value = 'bar';
2156+
});
2157+
2158+
scope2.$digest();
2159+
2160+
$browser.defer.flush(0);
2161+
2162+
expect(scope1.result).toBe('bar');
2163+
});
21452164
});
21462165

21472166
it('should not pass anything as `this` to scheduled functions', inject(function($rootScope) {

0 commit comments

Comments
 (0)