This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +11
-3
lines changed
2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -1944,6 +1944,7 @@ function $ParseProvider() {
1944
1944
return second ( first ( value ) ) ;
1945
1945
}
1946
1946
chainedInterceptor . $stateful = first . $stateful || second . $stateful ;
1947
+ chainedInterceptor . $pure = first . $pure && second . $pure ;
1947
1948
1948
1949
return chainedInterceptor ;
1949
1950
}
@@ -1979,14 +1980,18 @@ function $ParseProvider() {
1979
1980
// If the expression itself has no inputs then use the full expression as an input.
1980
1981
if ( ! interceptorFn . $stateful ) {
1981
1982
useInputs = ! parsedExpression . inputs ;
1982
- fn . inputs = ( parsedExpression . inputs ? parsedExpression . inputs : [ parsedExpression ] ) . map ( function ( e ) {
1983
+ fn . inputs = parsedExpression . inputs ? parsedExpression . inputs : [ parsedExpression ] ;
1984
+
1985
+ if ( ! interceptorFn . $pure ) {
1986
+ fn . inputs = fn . inputs . map ( function ( e ) {
1983
1987
// Remove the isPure flag of inputs when it is not absolute because they are now wrapped in a
1984
- // potentially non-pure interceptor function.
1988
+ // non-pure interceptor function.
1985
1989
if ( e . isPure === PURITY_RELATIVE ) {
1986
1990
return function depurifier ( s ) { return e ( s ) ; } ;
1987
1991
}
1988
1992
return e ;
1989
1993
} ) ;
1994
+ }
1990
1995
}
1991
1996
1992
1997
return addWatchDelegate ( fn ) ;
Original file line number Diff line number Diff line change @@ -581,7 +581,10 @@ function $RootScopeProvider() {
581
581
* de-registration function is executed, the internal watch operation is terminated.
582
582
*/
583
583
$watchCollection : function ( obj , listener ) {
584
- $watchCollectionInterceptor . $stateful = true ;
584
+ // If the expression is a literal then the interceptor is completely pure - it only results
585
+ // in a new object if one of its inputs (the collection values) changes.
586
+ // Otherwise mark it as $stateful to avoid any input-watching and always invoke the interceptor
587
+ $watchCollectionInterceptor . $stateful = ! ( $watchCollectionInterceptor . $pure = $parse ( obj ) . literal ) ;
585
588
586
589
var self = this ;
587
590
// the current value, updated on each dirty-check run
You can’t perform that action at this time.
0 commit comments