This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -1038,13 +1038,17 @@ function $RootScopeProvider() {
1038
1038
* @returns {* } The result of evaluating the expression.
1039
1039
*/
1040
1040
$apply : function ( expr ) {
1041
+ var doCleanPhase = false ;
1041
1042
try {
1042
1043
beginPhase ( '$apply' ) ;
1044
+ doCleanPhase = true ;
1043
1045
return this . $eval ( expr ) ;
1044
1046
} catch ( e ) {
1045
1047
$exceptionHandler ( e ) ;
1046
1048
} finally {
1047
- clearPhase ( ) ;
1049
+ if ( doCleanPhase ) {
1050
+ clearPhase ( ) ;
1051
+ }
1048
1052
try {
1049
1053
$rootScope . $digest ( ) ;
1050
1054
} catch ( e ) {
Original file line number Diff line number Diff line change @@ -1505,6 +1505,19 @@ describe('Scope', function() {
1505
1505
} ) ) ;
1506
1506
1507
1507
1508
+ it ( 'should not clear the state when calling $apply during an $apply' , inject (
1509
+ function ( $rootScope ) {
1510
+ $rootScope . $apply ( function ( ) {
1511
+ expect ( function ( ) {
1512
+ $rootScope . $apply ( ) ;
1513
+ } ) . toThrowMinErr ( '$rootScope' , 'inprog' , '$apply already in progress' ) ;
1514
+ expect ( function ( ) {
1515
+ $rootScope . $apply ( ) ;
1516
+ } ) . toThrowMinErr ( '$rootScope' , 'inprog' , '$apply already in progress' ) ;
1517
+ } ) ;
1518
+ } ) ) ;
1519
+
1520
+
1508
1521
it ( 'should throw an exception if $apply is called while flushing evalAsync queue' , inject (
1509
1522
function ( $rootScope ) {
1510
1523
expect ( function ( ) {
You can’t perform that action at this time.
0 commit comments