refactor(compiler): improve member expression check for v-on & v-model

This commit is contained in:
Evan You
2019-10-10 11:15:24 -04:00
parent 87c3d2edae
commit f11dadc1d2
9 changed files with 63 additions and 13 deletions

View File

@@ -63,8 +63,13 @@ export const walkJS: typeof walk = (ast, walker) => {
return walk(ast, walker)
}
const nonIdentifierRE = /^\d|[^\$\w]/
export const isSimpleIdentifier = (name: string): boolean =>
!/^\d|[^\$\w]/.test(name)
!nonIdentifierRE.test(name)
const memberExpRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\[[^\]]+\])*$/
export const isMemberExpression = (path: string): boolean =>
memberExpRE.test(path)
export function getInnerRange(
loc: SourceLocation,