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

Commit

Permalink
fix($rootScope): don't allow explicit digest calls to affect $evalAsync
Browse files Browse the repository at this point in the history
Fixes #15127

Closes #15494
  • Loading branch information
dcherman authored and gkalpak committed May 9, 2018
1 parent c3d5cc5 commit 02c0469
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/rootScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ function $RootScopeProvider() {
var watch, value, last, fn, get,
watchers,
dirty, ttl = TTL,
next, current, target = this,
next, current, target = asyncQueue.length ? $rootScope : this,
watchLog = [],
logIdx, asyncTask;

Expand Down
19 changes: 19 additions & 0 deletions test/ng/rootScopeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2142,6 +2142,25 @@ describe('Scope', function() {
$browser.defer.flush(100000);
expect(log).toEqual(['eval-ed 1!', 'eval-ed 2!']);
});

it('should not have execution affected by an explicit $digest call', function() {
var scope1 = $rootScope.$new();
var scope2 = $rootScope.$new();

scope1.$watch('value', function(value) {
scope1.result = value;
});

scope1.$evalAsync(function() {
scope1.value = 'bar';
});

scope2.$digest();

$browser.defer.flush(0);

expect(scope1.result).toBe('bar');
});
});

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

0 comments on commit 02c0469

Please sign in to comment.