Skip to content

Commit 5c2fe53

Browse files
committed
refactor(ssr): adjust renderToString implementation
1 parent 842b368 commit 5c2fe53

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

packages/server-renderer/src/renderToString.ts

+6-13
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import {
1212
Portal,
1313
ShapeFlags,
1414
ssrUtils,
15-
Slot,
16-
createApp
15+
Slot
1716
} from 'vue'
1817
import {
1918
isString,
@@ -84,22 +83,16 @@ function unrollBuffer(buffer: ResolvedSSRBuffer): string {
8483
}
8584

8685
export async function renderToString(input: App | VNode): Promise<string> {
87-
if (isVNode(input)) {
88-
return renderAppToString(createApp({ render: () => input }))
89-
} else {
90-
return renderAppToString(input)
91-
}
92-
}
93-
94-
async function renderAppToString(app: App): Promise<string> {
95-
const resolvedBuffer = await renderComponent(app._component, app._props, null)
86+
const resolvedBuffer = await (isVNode(input)
87+
? renderComponent({ render: () => input })
88+
: renderComponent(input._component, input._props))
9689
return unrollBuffer(resolvedBuffer)
9790
}
9891

9992
export function renderComponent(
10093
comp: Component,
101-
props: Props | null,
102-
children: VNodeNormalizedChildren | null,
94+
props: Props | null = null,
95+
children: VNodeNormalizedChildren | null = null,
10396
parentComponent: ComponentInternalInstance | null = null
10497
): ResolvedSSRBuffer | Promise<ResolvedSSRBuffer> {
10598
return renderComponentVNode(

0 commit comments

Comments
 (0)