fix(compiler-core): fix hoisting logic for elements with cached handlers + other bindings

fix #4327
This commit is contained in:
Evan You
2021-08-16 15:57:10 -04:00
parent 5b3f1e8424
commit a6c1db2728
3 changed files with 41 additions and 6 deletions

View File

@@ -335,16 +335,17 @@ function getGeneratedPropsConstantType(
if (keyType < returnType) {
returnType = keyType
}
if (value.type !== NodeTypes.SIMPLE_EXPRESSION) {
let valueType: ConstantTypes
if (value.type === NodeTypes.SIMPLE_EXPRESSION) {
valueType = getConstantType(value, context)
} else if (value.type === NodeTypes.JS_CALL_EXPRESSION) {
// some helper calls can be hoisted,
// such as the `normalizeProps` generated by the compiler for pre-normalize class,
// in this case we need to respect the ConstanType of the helper's argments
if (value.type === NodeTypes.JS_CALL_EXPRESSION) {
return getConstantTypeOfHelperCall(value, context)
}
return ConstantTypes.NOT_CONSTANT
valueType = getConstantTypeOfHelperCall(value, context)
} else {
valueType = ConstantTypes.NOT_CONSTANT
}
const valueType = getConstantType(value, context)
if (valueType === ConstantTypes.NOT_CONSTANT) {
return valueType
}