fix(compiler-core): allow multiline expression on v-model and v-on (#1234)

This commit is contained in:
Carlos Rodrigues
2020-06-09 22:24:48 +01:00
committed by GitHub
parent c97d1bae56
commit 958b6c80cf
5 changed files with 79 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
const expString =
exp.type === NodeTypes.SIMPLE_EXPRESSION ? exp.content : exp.loc.source
if (!isMemberExpression(expString)) {
context.onError(
createCompilerError(ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION, exp.loc)

View File

@@ -84,8 +84,10 @@ export const isSimpleIdentifier = (name: string): boolean =>
!nonIdentifierRE.test(name)
const memberExpRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\[[^\]]+\])*$/
export const isMemberExpression = (path: string): boolean =>
memberExpRE.test(path)
export const isMemberExpression = (path: string): boolean => {
if (!path) return false
return memberExpRE.test(path.trim())
}
export function getInnerRange(
loc: SourceLocation,