Skip to content

fix(runtime-vapor): prevent mounting functional components as virtual DOM #13385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: vapor
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/runtime-vapor/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand Down