fix(compiler-core): more robust member expression check when running in node

fix #4640
This commit is contained in:
Evan You
2021-09-21 12:19:27 -04:00
parent 7c3c28eb03
commit d23fde3d3b
4 changed files with 98 additions and 36 deletions

View File

@@ -41,7 +41,10 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
bindingType &&
bindingType !== BindingTypes.SETUP_CONST
if (!expString.trim() || (!isMemberExpression(expString) && !maybeRef)) {
if (
!expString.trim() ||
(!isMemberExpression(expString, context) && !maybeRef)
) {
context.onError(
createCompilerError(ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION, exp.loc)
)

View File

@@ -73,7 +73,7 @@ export const transformOn: DirectiveTransform = (
}
let shouldCache: boolean = context.cacheHandlers && !exp && !context.inVOnce
if (exp) {
const isMemberExp = isMemberExpression(exp.content)
const isMemberExp = isMemberExpression(exp.content, context)
const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content))
const hasMultipleStatements = exp.content.includes(`;`)