(parsedExpression, interceptorFn)
| 12788 | } |
| 12789 | |
| 12790 | function addInterceptor(parsedExpression, interceptorFn) { |
| 12791 | if (!interceptorFn) return parsedExpression; |
| 12792 | var watchDelegate = parsedExpression.$$watchDelegate; |
| 12793 | |
| 12794 | var regularWatch = |
| 12795 | watchDelegate !== oneTimeLiteralWatchDelegate && |
| 12796 | watchDelegate !== oneTimeWatchDelegate; |
| 12797 | |
| 12798 | var fn = regularWatch ? function regularInterceptedExpression(scope, locals) { |
| 12799 | var value = parsedExpression(scope, locals); |
| 12800 | return interceptorFn(value, scope, locals); |
| 12801 | } : function oneTimeInterceptedExpression(scope, locals) { |
| 12802 | var value = parsedExpression(scope, locals); |
| 12803 | var result = interceptorFn(value, scope, locals); |
| 12804 | // we only return the interceptor's result if the |
| 12805 | // initial value is defined (for bind-once) |
| 12806 | return isDefined(value) ? result : value; |
| 12807 | }; |
| 12808 | |
| 12809 | // Propagate $$watchDelegates other then inputsWatchDelegate |
| 12810 | if (parsedExpression.$$watchDelegate && |
| 12811 | parsedExpression.$$watchDelegate !== inputsWatchDelegate) { |
| 12812 | fn.$$watchDelegate = parsedExpression.$$watchDelegate; |
| 12813 | } else if (!interceptorFn.$stateful) { |
| 12814 | // If there is an interceptor, but no watchDelegate then treat the interceptor like |
| 12815 | // we treat filters - it is assumed to be a pure function unless flagged with $stateful |
| 12816 | fn.$$watchDelegate = inputsWatchDelegate; |
| 12817 | fn.inputs = [parsedExpression]; |
| 12818 | } |
| 12819 | |
| 12820 | return fn; |
| 12821 | } |
| 12822 | }]; |
| 12823 | } |
| 12824 |
no test coverage detected