diff --git a/packages/server-renderer/__tests__/render.spec.ts b/packages/server-renderer/__tests__/render.spec.ts index d0a5223b2ff..ad5fd01d1f1 100644 --- a/packages/server-renderer/__tests__/render.spec.ts +++ b/packages/server-renderer/__tests__/render.spec.ts @@ -1229,5 +1229,16 @@ function testRender(type: string, render: typeof renderToString) { // during the render phase expect(getterSpy).toHaveBeenCalledTimes(2) }) + + test('manually using the h function (return a HTMLElement)', async () => { + const MyNode = h('div', { id: 'aaaa' }) + const app = createSSRApp({ + ssrRender(_ctx, push, parent) { + push(ssrRenderComponent(MyNode, null, null, parent)) + }, + }) + const html = await render(app) + expect(html).toBe(`
`) + }) }) } diff --git a/packages/server-renderer/src/render.ts b/packages/server-renderer/src/render.ts index f04080b9c31..b261bb06795 100644 --- a/packages/server-renderer/src/render.ts +++ b/packages/server-renderer/src/render.ts @@ -93,6 +93,13 @@ export function renderComponentVNode( parentComponent: ComponentInternalInstance | null = null, slotScopeId?: string, ): SSRBuffer | Promise { + // vnode may be an ELEMENT + if (vnode.shapeFlag & ShapeFlags.ELEMENT) { + const { getBuffer, push } = createBuffer() + renderElementVNode(push, vnode, parentComponent!, slotScopeId) + return getBuffer() + } + const instance = (vnode.component = createComponentInstance( vnode, parentComponent,