This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix($parse): evaluate once simple expressions in interpolations
For simple expressions without filters that have a stateless interceptor then handle the 2nd phase parse evaluation using `inputs`. TL;DR This fixes the issue that interpolated simple expressions were evaluated twice within one digest loop. Long version, things happen in the following order: * There was an overhaul on $interpolate, this overhaul changed $parse and incorporated the concept of an interceptor. * Optimization on $parse landed so expressions that have filters without parameters (or the parameters are constants) would be evaluated in 2 phases, first to evaluate the expression sans the filter evaluation and then with the filter evaluation. This also used interceptors [the second evaluation issue was added here] * More optimizations on $parse landed and now expressions could be evaluated in 2 phases. One to get all the possible values that could change (lets call this state), the state was checked by $watch to know if an expression changed. The second to continue the evaluation (as long as this state is provided). This, once again, used interceptors The last change, was supposed to fix the issue, but there was an assumption in the existing code that the code would always generate the 2 phases functions, but that is not true. If the expression is simple enough (just like the one in your case) then the 2-phase evaluations functions are not generated. In this case, if a stateless interceptor was added (just like what $interpolate adds) then the state was not used and you see the function being evaluated twice. This explains why, if you change the expression from `Hello {{log('A')}} {{log('B')}}!` to `Hello {{log('A') + ' ' + log('B')}}!`, then the repetition is not there. Closes #12983 Closes #13002
- Loading branch information
1caf0b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be backported to 1.4?
1caf0b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Narretz I do not think there is a need, but would not oppose for this to be backported
1caf0b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we usually backport all fixes to the stable version?
1caf0b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backported to 1.4 as e403682