From d2c6e2d5b596aa1af4ca8b55565fe2ae6ce9827b Mon Sep 17 00:00:00 2001 From: zhiyuanzmj <260480378@qq.com> Date: Mon, 26 May 2025 20:08:55 +0800 Subject: [PATCH] fix(runtime-vapor): prevent mounting functional components as virtual DOM --- packages/runtime-vapor/src/component.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/runtime-vapor/src/component.ts b/packages/runtime-vapor/src/component.ts index 548babebf8b..00120eba6ec 100644 --- a/packages/runtime-vapor/src/component.ts +++ b/packages/runtime-vapor/src/component.ts @@ -144,8 +144,9 @@ export function createComponent( locateHydrationNode() } + const isFnComponent = isFunction(component) // vdom interop enabled and component is not an explicit vapor component - if (appContext.vapor && !component.__vapor) { + if (appContext.vapor && !isFnComponent && !component.__vapor) { const frag = appContext.vapor.vdomMount( component as any, rawProps, @@ -199,7 +200,7 @@ export function createComponent( setupPropsValidation(instance) } - const setupFn = isFunction(component) ? component : component.setup + const setupFn = isFnComponent ? component : component.setup const setupResult = setupFn ? callWithErrorHandling(setupFn, instance, ErrorCodes.SETUP_FUNCTION, [ instance.props, @@ -208,7 +209,7 @@ export function createComponent( : EMPTY_OBJ if (__DEV__ && !isBlock(setupResult)) { - if (isFunction(component)) { + if (isFnComponent) { warn(`Functional vapor component must return a block directly.`) instance.block = [] } else if (!component.render) {