From: Evan You Date: Mon, 27 Jul 2020 22:26:47 +0000 (-0400) Subject: fix(compiler-core/v-on): only cache empty handler when the option is used X-Git-Tag: v3.0.0-rc.5~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fbd1f4ccb22bf62bdf749460f8c6dadee3b6b89;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-core/v-on): only cache empty handler when the option is used fix #1716 The original idea is that the empty handler can be cached in all cases, but this contradicts with the assumption that `hasCachedProps` check in the static hoist transform can simply return `false` in the browser build. --- diff --git a/packages/compiler-core/src/transforms/vOn.ts b/packages/compiler-core/src/transforms/vOn.ts index 75759708bd..9bd5b2a46e 100644 --- a/packages/compiler-core/src/transforms/vOn.ts +++ b/packages/compiler-core/src/transforms/vOn.ts @@ -68,7 +68,7 @@ export const transformOn: DirectiveTransform = ( if (exp && !exp.content.trim()) { exp = undefined } - let isCacheable: boolean = !exp + let isCacheable: boolean = context.cacheHandlers && !exp if (exp) { const isMemberExp = isMemberExpression(exp.content) const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content))