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

fix($rootScope): Internal state consistency #12174

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/ng/rootScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -1040,14 +1040,17 @@ function $RootScopeProvider() {
$apply: function(expr) {
try {
beginPhase('$apply');
return this.$eval(expr);
} catch (e) {
try {
return this.$eval(expr);
} finally {
clearPhase();
}
} catch(e) {
$exceptionHandler(e);
} finally {
clearPhase();
try {
$rootScope.$digest();
} catch (e) {
} catch(e) {
$exceptionHandler(e);
throw e;
}
Expand Down
13 changes: 13 additions & 0 deletions test/ng/rootScopeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,19 @@ describe('Scope', function() {
}));


it('should not clear the state when calling $apply during an $apply', inject(
function($rootScope) {
$rootScope.$apply(function() {
expect(function() {
$rootScope.$apply();
}).toThrowMinErr('$rootScope', 'inprog', '$apply already in progress');
expect(function() {
$rootScope.$apply();
}).toThrowMinErr('$rootScope', 'inprog', '$apply already in progress');
});
}));


it('should throw an exception if $apply is called while flushing evalAsync queue', inject(
function($rootScope) {
expect(function() {
Expand Down