@@ -1798,15 +1798,9 @@ function $ParseProvider() {
1798
1798
var lexer = new Lexer ( $parseOptions ) ;
1799
1799
var parser = new Parser ( lexer , $filter , $parseOptions ) ;
1800
1800
parsedExpression = parser . parse ( exp ) ;
1801
- if ( parsedExpression . constant ) {
1802
- parsedExpression . $$watchDelegate = constantWatchDelegate ;
1803
- } else if ( oneTime ) {
1804
- parsedExpression . oneTime = true ;
1805
- parsedExpression . $$watchDelegate = oneTimeWatchDelegate ;
1806
- } else if ( parsedExpression . inputs ) {
1807
- parsedExpression . $$watchDelegate = inputsWatchDelegate ;
1808
- }
1809
- cache [ cacheKey ] = parsedExpression ;
1801
+ parsedExpression . oneTime = ! ! oneTime ;
1802
+
1803
+ cache [ cacheKey ] = addWatchDelegate ( parsedExpression ) ;
1810
1804
}
1811
1805
return addInterceptor ( parsedExpression , interceptorFn ) ;
1812
1806
@@ -1931,9 +1925,21 @@ function $ParseProvider() {
1931
1925
return unwatch ;
1932
1926
}
1933
1927
1928
+ function addWatchDelegate ( parsedExpression ) {
1929
+ if ( parsedExpression . constant ) {
1930
+ parsedExpression . $$watchDelegate = constantWatchDelegate ;
1931
+ } else if ( parsedExpression . oneTime ) {
1932
+ parsedExpression . $$watchDelegate = oneTimeWatchDelegate ;
1933
+ } else if ( parsedExpression . inputs ) {
1934
+ parsedExpression . $$watchDelegate = inputsWatchDelegate ;
1935
+ }
1936
+
1937
+ return parsedExpression ;
1938
+ }
1939
+
1934
1940
function addInterceptor ( parsedExpression , interceptorFn ) {
1935
1941
if ( ! interceptorFn ) return parsedExpression ;
1936
- var watchDelegate = parsedExpression . $$watchDelegate ;
1942
+
1937
1943
var useInputs = false ;
1938
1944
1939
1945
var isDone = parsedExpression . literal ? isAllDefined : isDefined ;
@@ -1953,18 +1959,16 @@ function $ParseProvider() {
1953
1959
1954
1960
var fn = parsedExpression . oneTime ? oneTimeInterceptedExpression : regularInterceptedExpression ;
1955
1961
1956
- // Propogate the literal/oneTime attributes
1962
+ // Propogate the literal/oneTime/constant attributes
1957
1963
fn . literal = parsedExpression . literal ;
1958
1964
fn . oneTime = parsedExpression . oneTime ;
1965
+ fn . constant = parsedExpression . constant ;
1959
1966
1960
- // Propagate or create inputs / $$watchDelegates
1961
- useInputs = ! parsedExpression . inputs ;
1962
- if ( watchDelegate && watchDelegate !== inputsWatchDelegate ) {
1963
- fn . $$watchDelegate = watchDelegate ;
1964
- fn . inputs = parsedExpression . inputs ;
1965
- } else if ( ! interceptorFn . $stateful ) {
1966
- // Treat interceptor like filters - assume non-stateful by default and use the inputsWatchDelegate
1967
- fn . $$watchDelegate = inputsWatchDelegate ;
1967
+ // Treat the interceptor like filters.
1968
+ // If it is not $stateful then only watch its inputs.
1969
+ // If the expression itself has no inputs then use the full expression as an input.
1970
+ if ( ! interceptorFn . $stateful ) {
1971
+ useInputs = ! parsedExpression . inputs ;
1968
1972
fn . inputs = ( parsedExpression . inputs ? parsedExpression . inputs : [ parsedExpression ] ) . map ( function ( e ) {
1969
1973
// Remove the isPure flag of inputs when it is not absolute because they are now wrapped in a
1970
1974
// potentially non-pure interceptor function.
@@ -1975,7 +1979,7 @@ function $ParseProvider() {
1975
1979
} ) ;
1976
1980
}
1977
1981
1978
- return fn ;
1982
+ return addWatchDelegate ( fn ) ;
1979
1983
}
1980
1984
} ] ;
1981
1985
}
0 commit comments