MCPcopy
hub / github.com/keepfool/vue-tutorials / compileGetter

Function compileGetter

06.Router/basic/js/vue.js:2899–2911  ·  view source on GitHub ↗

* Rewrite an expression, prefixing all path accessors with * `scope.` and generate getter/setter functions. * * @param {String} exp * @return {Function}

(exp)

Source from the content-addressed store, hash-verified

2897 */
2898
2899 function compileGetter(exp) {
2900 if (improperKeywordsRE.test(exp)) {
2901 'development' !== 'production' && warn('Avoid using reserved keywords in expression: ' + exp);
2902 }
2903 // reset state
2904 saved.length = 0;
2905 // save strings and object literal keys
2906 var body = exp.replace(saveRE, save).replace(wsRE, '');
2907 // rewrite all paths
2908 // pad 1 space here because the regex matches 1 extra char
2909 body = (' ' + body).replace(identRE, rewrite).replace(restoreRE, restore);
2910 return makeGetterFn(body);
2911 }
2912
2913 /**
2914 * Build a getter function. Requires eval.

Callers 1

parseExpressionFunction · 0.70

Calls 2

warnFunction · 0.70
makeGetterFnFunction · 0.70

Tested by

no test coverage detected