Skip to content
This repository has been 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

Conversation

lgalfaso
Copy link
Contributor

During a recursive $apply, clear the state only if the state was set in that call.

@lgalfaso lgalfaso force-pushed the no-clean-state branch 2 times, most recently from a1d319b to 301a737 Compare June 19, 2015 23:18
@petebacondarwin
Copy link
Member

Although this is logically correct, I find it unnecessarily complicated to follow. Instead, we should simply wrap the $eval in its own try-finally block:

        try {
          beginPhase('$apply');
          try {
            return this.$eval(expr);
          } finally {
            clearPhase();
          }
        } catch(e) {
          $exceptionHandler(e);
        } finally {
          try {
            $rootScope.$digest();
          } catch(e) {
            $exceptionHandler(e);
            throw e;
          }
        }

During a recursive $apply, clear the state only if the state was set in
that call.
@lgalfaso
Copy link
Contributor Author

@petebacondarwin I wanted to avoid the second try, but I think that your version of the fix makes it easier to read. Updated the patch with the recommended change

@lgalfaso lgalfaso closed this in 1815208 Jul 25, 2015
lgalfaso added a commit that referenced this pull request Jul 25, 2015
We cannot re-enter a `$apply` block while already in a `$apply` or `$digest`
phase.

Before this change such an invalid call to `$apply` was incorrectly clearing
the phase, which meant that a second invalid `$apply` call was being allowed.

Closes #12174
netman92 pushed a commit to netman92/angular.js that referenced this pull request Aug 8, 2015
We cannot re-enter a `$apply` block while already in a `$apply` or `$digest`
phase.

Before this change such an invalid call to `$apply` was incorrectly clearing
the phase, which meant that a second invalid `$apply` call was being allowed.

Closes angular#12174
ggershoni pushed a commit to ggershoni/angular.js that referenced this pull request Sep 29, 2015
We cannot re-enter a `$apply` block while already in a `$apply` or `$digest`
phase.

Before this change such an invalid call to `$apply` was incorrectly clearing
the phase, which meant that a second invalid `$apply` call was being allowed.

Closes angular#12174
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants