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

Commit 6393d6a

Browse files
committed
refactor($rootScope): items in asyncQueue are already $parsed, no need to call $eval
1 parent 493b496 commit 6393d6a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/ng/rootScope.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -786,12 +786,13 @@ function $RootScopeProvider() {
786786
current = target;
787787

788788
// It's safe for asyncQueuePosition to be a local variable here because this loop can't
789-
// be reentered recursively. Calling $digest from a function passed to $applyAsync would
789+
// be reentered recursively. Calling $digest from a function passed to $evalAsync would
790790
// lead to a '$digest already in progress' error.
791791
for (var asyncQueuePosition = 0; asyncQueuePosition < asyncQueue.length; asyncQueuePosition++) {
792792
try {
793793
asyncTask = asyncQueue[asyncQueuePosition];
794-
asyncTask.scope.$eval(asyncTask.expression, asyncTask.locals);
794+
fn = asyncTask.fn;
795+
fn(asyncTask.scope, asyncTask.locals);
795796
} catch (e) {
796797
$exceptionHandler(e);
797798
}
@@ -1025,7 +1026,7 @@ function $RootScopeProvider() {
10251026
});
10261027
}
10271028

1028-
asyncQueue.push({scope: this, expression: $parse(expr), locals: locals});
1029+
asyncQueue.push({scope: this, fn: $parse(expr), locals: locals});
10291030
},
10301031

10311032
$$postDigest: function(fn) {

test/ng/rootScopeSpec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,9 +1444,9 @@ describe('Scope', function() {
14441444
expect(childScope.$$asyncQueue).toBe($rootScope.$$asyncQueue);
14451445
expect(isolateScope.$$asyncQueue).toBeUndefined();
14461446
expect($rootScope.$$asyncQueue).toEqual([
1447-
{scope: $rootScope, expression: $parse('rootExpression'), locals: undefined},
1448-
{scope: childScope, expression: $parse('childExpression'), locals: undefined},
1449-
{scope: isolateScope, expression: $parse('isolateExpression'), locals: undefined}
1447+
{scope: $rootScope, fn: $parse('rootExpression'), locals: undefined},
1448+
{scope: childScope, fn: $parse('childExpression'), locals: undefined},
1449+
{scope: isolateScope, fn: $parse('isolateExpression'), locals: undefined}
14501450
]);
14511451
}));
14521452

0 commit comments

Comments
 (0)