Skip to content

Commit a318de6

Browse files
committed
fix($rootScope): don't allow explicit digest calls to affect $evalAsync
Fixes angular#15127
1 parent 7f8bc58 commit a318de6

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
@@ -764,7 +764,7 @@ function $RootScopeProvider() {
764764
var watch, value, last, fn, get,
765765
watchers,
766766
dirty, ttl = TTL,
767-
next, current, target = this,
767+
next, current, target = asyncQueue.length ? $rootScope : this,
768768
watchLog = [],
769769
logIdx, asyncTask;
770770

test/ng/rootScopeSpec.js

+19
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,25 @@ describe('Scope', function() {
14981498
$browser.defer.flush(100000);
14991499
expect(log).toEqual(['eval-ed 1!', 'eval-ed 2!']);
15001500
});
1501+
1502+
it('should not have execution affected by an explicit $digest call', function() {
1503+
var scope1 = $rootScope.$new();
1504+
var scope2 = $rootScope.$new();
1505+
1506+
scope1.$watch('value', function(value) {
1507+
scope1.result = value;
1508+
});
1509+
1510+
scope1.$evalAsync(function() {
1511+
scope1.value = 'bar';
1512+
});
1513+
1514+
scope2.$digest();
1515+
1516+
$browser.defer.flush(0);
1517+
1518+
expect(scope1.result).toBe('bar');
1519+
});
15011520
});
15021521
});
15031522

0 commit comments

Comments
 (0)