]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compat): fix v3 compiled fn detection in production
authorEvan You <yyx990803@gmail.com>
Fri, 16 Jul 2021 14:17:38 +0000 (10:17 -0400)
committerEvan You <yyx990803@gmail.com>
Fri, 16 Jul 2021 14:17:38 +0000 (10:17 -0400)
packages/runtime-core/src/compat/renderFn.ts

index 480bf029a0fcd9666d7072c281a43700c8cd3cc9..69ca1d7cbe259f784b7f696dab8c23aa0c7da957 100644 (file)
@@ -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
   }