From 8c430e1e1adcf7a83599a728cad68cc24f3bba4e Mon Sep 17 00:00:00 2001 From: linzhe141 <1572213544@qq.com> Date: Thu, 12 Dec 2024 11:29:01 +0800 Subject: [PATCH 1/2] fix(ssr): handle manually using the h function (return a HTMLElement) --- packages/server-renderer/__tests__/render.spec.ts | 11 +++++++++++ packages/server-renderer/src/render.ts | 5 +++++ 2 files changed, 16 insertions(+) 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..d433ca266d4 100644 --- a/packages/server-renderer/src/render.ts +++ b/packages/server-renderer/src/render.ts @@ -93,6 +93,11 @@ export function renderComponentVNode( parentComponent: ComponentInternalInstance | null = null, slotScopeId?: string, ): SSRBuffer | Promise