MCPcopy Create free account
hub / github.com/dashnowords/imfe / parseModel

Function parseModel

chapter17/vue.js:7220–7258  ·  view source on GitHub ↗
(val)

Source from the content-addressed store, hash-verified

7218
7219
7220 function parseModel (val) {
7221 // Fix https://github.com/vuejs/vue/pull/7730
7222 // allow v-model="obj.val " (trailing whitespace)
7223 val = val.trim();
7224 len = val.length;
7225
7226 if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
7227 index$1 = val.lastIndexOf('.');
7228 if (index$1 > -1) {
7229 return {
7230 exp: val.slice(0, index$1),
7231 key: '"' + val.slice(index$1 + 1) + '"'
7232 }
7233 } else {
7234 return {
7235 exp: val,
7236 key: null
7237 }
7238 }
7239 }
7240
7241 str = val;
7242 index$1 = expressionPos = expressionEndPos = 0;
7243
7244 while (!eof()) {
7245 chr = next();
7246 /* istanbul ignore if */
7247 if (isStringStart(chr)) {
7248 parseString(chr);
7249 } else if (chr === 0x5B) {
7250 parseBracket(chr);
7251 }
7252 }
7253
7254 return {
7255 exp: val.slice(0, expressionPos),
7256 key: val.slice(expressionPos + 1, expressionEndPos)
7257 }
7258 }
7259
7260 function next () {
7261 return str.charCodeAt(++index$1)

Callers 1

genAssignmentCodeFunction · 0.85

Calls 5

eofFunction · 0.85
isStringStartFunction · 0.85
parseStringFunction · 0.85
parseBracketFunction · 0.85
nextFunction · 0.70

Tested by

no test coverage detected