Skip to content

Commit

Permalink
fix(compat): fix v3 compiled fn detection in production
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 16, 2021
1 parent 68365b9 commit 8dbad83
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/runtime-core/src/compat/renderFn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit 8dbad83

Please sign in to comment.