@@ -1795,15 +1795,9 @@ function $ParseProvider() {
1795
1795
var lexer = new Lexer ( $parseOptions ) ;
1796
1796
var parser = new Parser ( lexer , $filter , $parseOptions ) ;
1797
1797
parsedExpression = parser . parse ( exp ) ;
1798
- if ( parsedExpression . constant ) {
1799
- parsedExpression . $$watchDelegate = constantWatchDelegate ;
1800
- } else if ( oneTime ) {
1801
- parsedExpression . oneTime = true ;
1802
- parsedExpression . $$watchDelegate = oneTimeWatchDelegate ;
1803
- } else if ( parsedExpression . inputs ) {
1804
- parsedExpression . $$watchDelegate = inputsWatchDelegate ;
1805
- }
1806
- cache [ cacheKey ] = parsedExpression ;
1798
+ parsedExpression . oneTime = ! ! oneTime ;
1799
+
1800
+ cache [ cacheKey ] = addWatchDelegate ( parsedExpression ) ;
1807
1801
}
1808
1802
return addInterceptor ( parsedExpression , interceptorFn ) ;
1809
1803
@@ -1928,9 +1922,21 @@ function $ParseProvider() {
1928
1922
return unwatch ;
1929
1923
}
1930
1924
1925
+ function addWatchDelegate ( parsedExpression ) {
1926
+ if ( parsedExpression . constant ) {
1927
+ parsedExpression . $$watchDelegate = constantWatchDelegate ;
1928
+ } else if ( parsedExpression . oneTime ) {
1929
+ parsedExpression . $$watchDelegate = oneTimeWatchDelegate ;
1930
+ } else if ( parsedExpression . inputs ) {
1931
+ parsedExpression . $$watchDelegate = inputsWatchDelegate ;
1932
+ }
1933
+
1934
+ return parsedExpression ;
1935
+ }
1936
+
1931
1937
function addInterceptor ( parsedExpression , interceptorFn ) {
1932
1938
if ( ! interceptorFn ) return parsedExpression ;
1933
- var watchDelegate = parsedExpression . $$watchDelegate ;
1939
+
1934
1940
var useInputs = false ;
1935
1941
1936
1942
var isDone = parsedExpression . literal ? isAllDefined : isDefined ;
@@ -1950,23 +1956,20 @@ function $ParseProvider() {
1950
1956
1951
1957
var fn = parsedExpression . oneTime ? oneTimeInterceptedExpression : regularInterceptedExpression ;
1952
1958
1953
- // Propogate the literal/oneTime attributes
1959
+ // Propogate the literal/oneTime/constant attributes
1954
1960
fn . literal = parsedExpression . literal ;
1955
1961
fn . oneTime = parsedExpression . oneTime ;
1962
+ fn . constant = parsedExpression . constant ;
1956
1963
1957
- // Propagate or create inputs / $$watchDelegates
1958
- useInputs = ! parsedExpression . inputs ;
1959
- if ( watchDelegate && watchDelegate !== inputsWatchDelegate ) {
1960
- fn . $$watchDelegate = watchDelegate ;
1961
- fn . inputs = parsedExpression . inputs ;
1962
- } else if ( ! interceptorFn . $stateful ) {
1963
- // If there is an interceptor, but no watchDelegate then treat the interceptor like
1964
- // we treat filters - it is assumed to be a pure function unless flagged with $stateful
1965
- fn . $$watchDelegate = inputsWatchDelegate ;
1964
+ // Treat the interceptor like filters.
1965
+ // If it is not $stateful then only watch its inputs.
1966
+ // If the expression itself has no inputs then use the full expression as an input.
1967
+ if ( ! interceptorFn . $stateful ) {
1968
+ useInputs = ! parsedExpression . inputs ;
1966
1969
fn . inputs = parsedExpression . inputs ? parsedExpression . inputs : [ parsedExpression ] ;
1967
1970
}
1968
1971
1969
- return fn ;
1972
+ return addWatchDelegate ( fn ) ;
1970
1973
}
1971
1974
} ] ;
1972
1975
}
0 commit comments