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