MCPcopy Index your code
hub / github.com/keepfool/vue-tutorials / parseExpression

Function parseExpression

01.GettingStarted/js/vue.js:2967–2988  ·  view source on GitHub ↗

* Parse an expression into re-written getter/setters. * * @param {String} exp * @param {Boolean} needSet * @return {Function}

(exp, needSet)

Source from the content-addressed store, hash-verified

2965 */
2966
2967 function parseExpression(exp, needSet) {
2968 exp = exp.trim();
2969 // try cache
2970 var hit = expressionCache.get(exp);
2971 if (hit) {
2972 if (needSet && !hit.set) {
2973 hit.set = compileSetter(hit.exp);
2974 }
2975 return hit;
2976 }
2977 var res = { exp: exp };
2978 res.get = isSimplePath(exp) && exp.indexOf('[') < 0
2979 // optimized super simple getter
2980 ? makeGetterFn('scope.' + exp)
2981 // dynamic getter
2982 : compileGetter(exp);
2983 if (needSet) {
2984 res.set = compileSetter(exp);
2985 }
2986 expressionCache.put(exp, res);
2987 return res;
2988 }
2989
2990 /**
2991 * Check if an expression is a simple path.

Callers 5

getPathFunction · 0.70
setPathFunction · 0.70
WatcherFunction · 0.70
vue.jsFile · 0.70
dataAPIFunction · 0.70

Calls 4

compileSetterFunction · 0.70
isSimplePathFunction · 0.70
makeGetterFnFunction · 0.70
compileGetterFunction · 0.70

Tested by

no test coverage detected