MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / $ParseProvider

Function $ParseProvider

lib/test/angular/1.4.3/angular.js:14040–14251  ·  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

14038 * service.
14039 */
14040function $ParseProvider() {
14041 var cacheDefault = createMap();
14042 var cacheExpensive = createMap();
14043
14044 this.$get = ['$filter', '$sniffer', function($filter, $sniffer) {
14045 var $parseOptions = {
14046 csp: $sniffer.csp,
14047 expensiveChecks: false
14048 },
14049 $parseOptionsExpensive = {
14050 csp: $sniffer.csp,
14051 expensiveChecks: true
14052 };
14053
14054 return function $parse(exp, interceptorFn, expensiveChecks) {
14055 var parsedExpression, oneTime, cacheKey;
14056
14057 switch (typeof exp) {
14058 case 'string':
14059 exp = exp.trim();
14060 cacheKey = exp;
14061
14062 var cache = (expensiveChecks ? cacheExpensive : cacheDefault);
14063 parsedExpression = cache[cacheKey];
14064
14065 if (!parsedExpression) {
14066 if (exp.charAt(0) === ':' && exp.charAt(1) === ':') {
14067 oneTime = true;
14068 exp = exp.substring(2);
14069 }
14070 var parseOptions = expensiveChecks ? $parseOptionsExpensive : $parseOptions;
14071 var lexer = new Lexer(parseOptions);
14072 var parser = new Parser(lexer, $filter, parseOptions);
14073 parsedExpression = parser.parse(exp);
14074 if (parsedExpression.constant) {
14075 parsedExpression.$$watchDelegate = constantWatchDelegate;
14076 } else if (oneTime) {
14077 parsedExpression.$$watchDelegate = parsedExpression.literal ?
14078 oneTimeLiteralWatchDelegate : oneTimeWatchDelegate;
14079 } else if (parsedExpression.inputs) {
14080 parsedExpression.$$watchDelegate = inputsWatchDelegate;
14081 }
14082 cache[cacheKey] = parsedExpression;
14083 }
14084 return addInterceptor(parsedExpression, interceptorFn);
14085
14086 case 'function':
14087 return addInterceptor(exp, interceptorFn);
14088
14089 default:
14090 return noop;
14091 }
14092 };
14093
14094 function expressionInputDirtyCheck(newValue, oldValueOfValue) {
14095
14096 if (newValue == null || oldValueOfValue == null) { // null/undefined
14097 return newValue === oldValueOfValue;

Callers

nothing calls this directly

Calls 2

createMapFunction · 0.70
addInterceptorFunction · 0.70

Tested by

no test coverage detected