(parsedExpression, interceptorFn)
| 12969 | } |
| 12970 | |
| 12971 | function addInterceptor(parsedExpression, interceptorFn) { |
| 12972 | if (!interceptorFn) return parsedExpression; |
| 12973 | var watchDelegate = parsedExpression.$$watchDelegate; |
| 12974 | |
| 12975 | var regularWatch = |
| 12976 | watchDelegate !== oneTimeLiteralWatchDelegate && |
| 12977 | watchDelegate !== oneTimeWatchDelegate; |
| 12978 | |
| 12979 | var fn = regularWatch ? function regularInterceptedExpression(scope, locals) { |
| 12980 | var value = parsedExpression(scope, locals); |
| 12981 | return interceptorFn(value, scope, locals); |
| 12982 | } : function oneTimeInterceptedExpression(scope, locals) { |
| 12983 | var value = parsedExpression(scope, locals); |
| 12984 | var result = interceptorFn(value, scope, locals); |
| 12985 | // we only return the interceptor's result if the |
| 12986 | // initial value is defined (for bind-once) |
| 12987 | return isDefined(value) ? result : value; |
| 12988 | }; |
| 12989 | |
| 12990 | // Propagate $$watchDelegates other then inputsWatchDelegate |
| 12991 | if (parsedExpression.$$watchDelegate && |
| 12992 | parsedExpression.$$watchDelegate !== inputsWatchDelegate) { |
| 12993 | fn.$$watchDelegate = parsedExpression.$$watchDelegate; |
| 12994 | } else if (!interceptorFn.$stateful) { |
| 12995 | // If there is an interceptor, but no watchDelegate then treat the interceptor like |
| 12996 | // we treat filters - it is assumed to be a pure function unless flagged with $stateful |
| 12997 | fn.$$watchDelegate = inputsWatchDelegate; |
| 12998 | fn.inputs = [parsedExpression]; |
| 12999 | } |
| 13000 | |
| 13001 | return fn; |
| 13002 | } |
| 13003 | }]; |
| 13004 | } |
| 13005 |
no test coverage detected