From: Evan You Date: Thu, 13 Feb 2020 23:34:08 +0000 (-0500) Subject: fix(compiler-core): should not hoist element with cached + merged event handlers X-Git-Tag: v3.0.0-alpha.5~40 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5455e8e69a59cd1ff72330b1aed9c8e6aedc4b36;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-core): should not hoist element with cached + merged event handlers --- diff --git a/packages/compiler-core/src/transforms/hoistStatic.ts b/packages/compiler-core/src/transforms/hoistStatic.ts index da44a1ecb5..968fc59120 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 } }