* @ngdoc provider * @name $parseProvider * * @description * `$parseProvider` can be used for configuring the default behavior of the ng.$parse $parse * service.
()
| 14212 | * service. |
| 14213 | */ |
| 14214 | function $ParseProvider() { |
| 14215 | var cacheDefault = createMap(); |
| 14216 | var cacheExpensive = createMap(); |
| 14217 | |
| 14218 | this.$get = ['$filter', function($filter) { |
| 14219 | var noUnsafeEval = csp().noUnsafeEval; |
| 14220 | var $parseOptions = { |
| 14221 | csp: noUnsafeEval, |
| 14222 | expensiveChecks: false |
| 14223 | }, |
| 14224 | $parseOptionsExpensive = { |
| 14225 | csp: noUnsafeEval, |
| 14226 | expensiveChecks: true |
| 14227 | }; |
| 14228 | |
| 14229 | return function $parse(exp, interceptorFn, expensiveChecks) { |
| 14230 | var parsedExpression, oneTime, cacheKey; |
| 14231 | |
| 14232 | switch (typeof exp) { |
| 14233 | case 'string': |
| 14234 | exp = exp.trim(); |
| 14235 | cacheKey = exp; |
| 14236 | |
| 14237 | var cache = (expensiveChecks ? cacheExpensive : cacheDefault); |
| 14238 | parsedExpression = cache[cacheKey]; |
| 14239 | |
| 14240 | if (!parsedExpression) { |
| 14241 | if (exp.charAt(0) === ':' && exp.charAt(1) === ':') { |
| 14242 | oneTime = true; |
| 14243 | exp = exp.substring(2); |
| 14244 | } |
| 14245 | var parseOptions = expensiveChecks ? $parseOptionsExpensive : $parseOptions; |
| 14246 | var lexer = new Lexer(parseOptions); |
| 14247 | var parser = new Parser(lexer, $filter, parseOptions); |
| 14248 | parsedExpression = parser.parse(exp); |
| 14249 | if (parsedExpression.constant) { |
| 14250 | parsedExpression.$$watchDelegate = constantWatchDelegate; |
| 14251 | } else if (oneTime) { |
| 14252 | parsedExpression.$$watchDelegate = parsedExpression.literal ? |
| 14253 | oneTimeLiteralWatchDelegate : oneTimeWatchDelegate; |
| 14254 | } else if (parsedExpression.inputs) { |
| 14255 | parsedExpression.$$watchDelegate = inputsWatchDelegate; |
| 14256 | } |
| 14257 | cache[cacheKey] = parsedExpression; |
| 14258 | } |
| 14259 | return addInterceptor(parsedExpression, interceptorFn); |
| 14260 | |
| 14261 | case 'function': |
| 14262 | return addInterceptor(exp, interceptorFn); |
| 14263 | |
| 14264 | default: |
| 14265 | return noop; |
| 14266 | } |
| 14267 | }; |
| 14268 | |
| 14269 | function expressionInputDirtyCheck(newValue, oldValueOfValue) { |
| 14270 | |
| 14271 | if (newValue == null || oldValueOfValue == null) { // null/undefined |
nothing calls this directly
no test coverage detected