This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +25
-7
lines changed
2 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -1040,17 +1040,22 @@ function $RootScopeProvider() {
1040
1040
$apply : function ( expr ) {
1041
1041
try {
1042
1042
beginPhase ( '$apply' ) ;
1043
- return this . $eval ( expr ) ;
1044
- } catch ( e ) {
1045
- $exceptionHandler ( e ) ;
1046
- } finally {
1047
- clearPhase ( ) ;
1048
1043
try {
1049
- $rootScope . $digest ( ) ;
1044
+ return this . $eval ( expr ) ;
1050
1045
} catch ( e ) {
1051
1046
$exceptionHandler ( e ) ;
1052
- throw e ;
1047
+ } finally {
1048
+ clearPhase ( ) ;
1049
+ try {
1050
+ $rootScope . $digest ( ) ;
1051
+ } catch ( e ) {
1052
+ $exceptionHandler ( e ) ;
1053
+ throw e ;
1054
+ }
1053
1055
}
1056
+ } catch ( e ) {
1057
+ $exceptionHandler ( e ) ;
1058
+ throw e ;
1054
1059
}
1055
1060
} ,
1056
1061
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