This commit is contained in:
linzhe 2025-05-05 20:38:37 +00:00 committed by GitHub
commit 5073d1c873
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View File

@ -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(`<div id="aaaa"></div>`)
})
})
}

View File

@ -93,6 +93,13 @@ export function renderComponentVNode(
parentComponent: ComponentInternalInstance | null = null,
slotScopeId?: string,
): SSRBuffer | Promise<SSRBuffer> {
// 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,