MCPcopy
hub / github.com/angular-ui/ui-router / $ParseProvider

Function $ParseProvider

test/angular/1.4/angular.js:14551–14801  ·  view source on GitHub ↗

* @ngdoc provider * @name $parseProvider * * @description * `$parseProvider` can be used for configuring the default behavior of the ng.$parse $parse * service.

()

Source from the content-addressed store, hash-verified

14549 * service.
14550 */
14551function $ParseProvider() {
14552 var cacheDefault = createMap();
14553 var cacheExpensive = createMap();
14554
14555 this.$get = ['$filter', function($filter) {
14556 var noUnsafeEval = csp().noUnsafeEval;
14557 var $parseOptions = {
14558 csp: noUnsafeEval,
14559 expensiveChecks: false
14560 },
14561 $parseOptionsExpensive = {
14562 csp: noUnsafeEval,
14563 expensiveChecks: true
14564 };
14565 var runningChecksEnabled = false;
14566
14567 $parse.$$runningExpensiveChecks = function() {
14568 return runningChecksEnabled;
14569 };
14570
14571 return $parse;
14572
14573 function $parse(exp, interceptorFn, expensiveChecks) {
14574 var parsedExpression, oneTime, cacheKey;
14575
14576 expensiveChecks = expensiveChecks || runningChecksEnabled;
14577
14578 switch (typeof exp) {
14579 case 'string':
14580 exp = exp.trim();
14581 cacheKey = exp;
14582
14583 var cache = (expensiveChecks ? cacheExpensive : cacheDefault);
14584 parsedExpression = cache[cacheKey];
14585
14586 if (!parsedExpression) {
14587 if (exp.charAt(0) === ':' && exp.charAt(1) === ':') {
14588 oneTime = true;
14589 exp = exp.substring(2);
14590 }
14591 var parseOptions = expensiveChecks ? $parseOptionsExpensive : $parseOptions;
14592 var lexer = new Lexer(parseOptions);
14593 var parser = new Parser(lexer, $filter, parseOptions);
14594 parsedExpression = parser.parse(exp);
14595 if (parsedExpression.constant) {
14596 parsedExpression.$$watchDelegate = constantWatchDelegate;
14597 } else if (oneTime) {
14598 parsedExpression.$$watchDelegate = parsedExpression.literal ?
14599 oneTimeLiteralWatchDelegate : oneTimeWatchDelegate;
14600 } else if (parsedExpression.inputs) {
14601 parsedExpression.$$watchDelegate = inputsWatchDelegate;
14602 }
14603 if (expensiveChecks) {
14604 parsedExpression = expensiveChecksInterceptor(parsedExpression);
14605 }
14606 cache[cacheKey] = parsedExpression;
14607 }
14608 return addInterceptor(parsedExpression, interceptorFn);

Callers

nothing calls this directly

Calls 2

createMapFunction · 0.70
cspFunction · 0.70

Tested by

no test coverage detected