From 8dbad83e7fa39be3e61ca694a6090c1646117953 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 16 Jul 2021 10:17:38 -0400 Subject: [PATCH] fix(compat): fix v3 compiled fn detection in production --- packages/runtime-core/src/compat/renderFn.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/runtime-core/src/compat/renderFn.ts b/packages/runtime-core/src/compat/renderFn.ts index 480bf029a0f..69ca1d7cbe2 100644 --- a/packages/runtime-core/src/compat/renderFn.ts +++ b/packages/runtime-core/src/compat/renderFn.ts @@ -39,8 +39,6 @@ import { } from './compatConfig' import { compatModelEventPrefix } from './componentVModel' -const v3CompiledRenderFnRE = /^(?:function \w*)?\(_ctx, _cache/ - export function convertLegacyRenderFn(instance: ComponentInternalInstance) { const Component = instance.type as ComponentOptions const render = Component.render as InternalRenderFunction | undefined @@ -50,8 +48,10 @@ export function convertLegacyRenderFn(instance: ComponentInternalInstance) { return } - if (v3CompiledRenderFnRE.test(render.toString())) { - // v3 pre-compiled function + if (render.length >= 2) { + // v3 pre-compiled function, since v2 render functions never need more than + // 2 arguments, and v2 functional render functions would have already been + // normalized into v3 functional components render._compatChecked = true return }