From 5455e8e69a59cd1ff72330b1aed9c8e6aedc4b36 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 13 Feb 2020 18:34:08 -0500 Subject: [PATCH] fix(compiler-core): should not hoist element with cached + merged event handlers --- packages/compiler-core/src/transforms/hoistStatic.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/compiler-core/src/transforms/hoistStatic.ts b/packages/compiler-core/src/transforms/hoistStatic.ts index da44a1ec..968fc591 100644 --- a/packages/compiler-core/src/transforms/hoistStatic.ts +++ b/packages/compiler-core/src/transforms/hoistStatic.ts @@ -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 } }