(parsedExpression, interceptorFn)
| 14216 | } |
| 14217 | |
| 14218 | function addInterceptor(parsedExpression, interceptorFn) { |
| 14219 | if (!interceptorFn) return parsedExpression; |
| 14220 | var watchDelegate = parsedExpression.$$watchDelegate; |
| 14221 | |
| 14222 | var regularWatch = |
| 14223 | watchDelegate !== oneTimeLiteralWatchDelegate && |
| 14224 | watchDelegate !== oneTimeWatchDelegate; |
| 14225 | |
| 14226 | var fn = regularWatch ? function regularInterceptedExpression(scope, locals, assign, inputs) { |
| 14227 | var value = parsedExpression(scope, locals, assign, inputs); |
| 14228 | return interceptorFn(value, scope, locals); |
| 14229 | } : function oneTimeInterceptedExpression(scope, locals, assign, inputs) { |
| 14230 | var value = parsedExpression(scope, locals, assign, inputs); |
| 14231 | var result = interceptorFn(value, scope, locals); |
| 14232 | // we only return the interceptor's result if the |
| 14233 | // initial value is defined (for bind-once) |
| 14234 | return isDefined(value) ? result : value; |
| 14235 | }; |
| 14236 | |
| 14237 | // Propagate $$watchDelegates other then inputsWatchDelegate |
| 14238 | if (parsedExpression.$$watchDelegate && |
| 14239 | parsedExpression.$$watchDelegate !== inputsWatchDelegate) { |
| 14240 | fn.$$watchDelegate = parsedExpression.$$watchDelegate; |
| 14241 | } else if (!interceptorFn.$stateful) { |
| 14242 | // If there is an interceptor, but no watchDelegate then treat the interceptor like |
| 14243 | // we treat filters - it is assumed to be a pure function unless flagged with $stateful |
| 14244 | fn.$$watchDelegate = inputsWatchDelegate; |
| 14245 | fn.inputs = parsedExpression.inputs ? parsedExpression.inputs : [parsedExpression]; |
| 14246 | } |
| 14247 | |
| 14248 | return fn; |
| 14249 | } |
| 14250 | }]; |
| 14251 | } |
| 14252 |
no test coverage detected