@@ -1798,15 +1798,9 @@ function $ParseProvider() {
17981798 var lexer = new Lexer ( $parseOptions ) ;
17991799 var parser = new Parser ( lexer , $filter , $parseOptions ) ;
18001800 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 ) ;
18101804 }
18111805 return addInterceptor ( parsedExpression , interceptorFn ) ;
18121806
@@ -1931,9 +1925,21 @@ function $ParseProvider() {
19311925 return unwatch ;
19321926 }
19331927
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+
19341940 function addInterceptor ( parsedExpression , interceptorFn ) {
19351941 if ( ! interceptorFn ) return parsedExpression ;
1936- var watchDelegate = parsedExpression . $$watchDelegate ;
1942+
19371943 var useInputs = false ;
19381944
19391945 var isDone = parsedExpression . literal ? isAllDefined : isDefined ;
@@ -1953,18 +1959,16 @@ function $ParseProvider() {
19531959
19541960 var fn = parsedExpression . oneTime ? oneTimeInterceptedExpression : regularInterceptedExpression ;
19551961
1956- // Propogate the literal/oneTime attributes
1962+ // Propogate the literal/oneTime/constant attributes
19571963 fn . literal = parsedExpression . literal ;
19581964 fn . oneTime = parsedExpression . oneTime ;
1965+ fn . constant = parsedExpression . constant ;
19591966
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 ;
19681972 fn . inputs = ( parsedExpression . inputs ? parsedExpression . inputs : [ parsedExpression ] ) . map ( function ( e ) {
19691973 // Remove the isPure flag of inputs when it is not absolute because they are now wrapped in a
19701974 // potentially non-pure interceptor function.
@@ -1975,7 +1979,7 @@ function $ParseProvider() {
19751979 } ) ;
19761980 }
19771981
1978- return fn ;
1982+ return addWatchDelegate ( fn ) ;
19791983 }
19801984 } ] ;
19811985}
0 commit comments