fix(compiler-core): should not hoist element with cached + merged event handlers

This commit is contained in:
Evan You 2020-02-13 18:34:08 -05:00
parent 9aaef60ad2
commit 5455e8e69a

View File

@ -176,7 +176,17 @@ function hasCachedProps(node: PlainElementNode): boolean {
if (props && props.type === NodeTypes.JS_OBJECT_EXPRESSION) {
const { properties } = props
for (let i = 0; i < properties.length; i++) {
if (properties[i].value.type === NodeTypes.JS_CACHE_EXPRESSION) {
const val = properties[i].value
if (val.type === NodeTypes.JS_CACHE_EXPRESSION) {
return true
}
// merged event handlers
if (
val.type === NodeTypes.JS_ARRAY_EXPRESSION &&
val.elements.some(
e => !isString(e) && e.type === NodeTypes.JS_CACHE_EXPRESSION
)
) {
return true
}
}