From: Evan You Date: Thu, 30 Jan 2020 17:09:50 +0000 (-0500) Subject: refactor(ssr): adjust renderToString implementation X-Git-Tag: v3.0.0-alpha.5~150 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5c2fe536dcb0080500cb05798e7de1628a494094;p=thirdparty%2Fvuejs%2Fcore.git refactor(ssr): adjust renderToString implementation --- diff --git a/packages/server-renderer/src/renderToString.ts b/packages/server-renderer/src/renderToString.ts index ebf96624cf..6efa66324a 100644 --- a/packages/server-renderer/src/renderToString.ts +++ b/packages/server-renderer/src/renderToString.ts @@ -12,8 +12,7 @@ import { Portal, ShapeFlags, ssrUtils, - Slot, - createApp + Slot } from 'vue' import { isString, @@ -84,22 +83,16 @@ function unrollBuffer(buffer: ResolvedSSRBuffer): string { } export async function renderToString(input: App | VNode): Promise { - if (isVNode(input)) { - return renderAppToString(createApp({ render: () => input })) - } else { - return renderAppToString(input) - } -} - -async function renderAppToString(app: App): Promise { - const resolvedBuffer = await renderComponent(app._component, app._props, null) + const resolvedBuffer = await (isVNode(input) + ? renderComponent({ render: () => input }) + : renderComponent(input._component, input._props)) return unrollBuffer(resolvedBuffer) } export function renderComponent( comp: Component, - props: Props | null, - children: VNodeNormalizedChildren | null, + props: Props | null = null, + children: VNodeNormalizedChildren | null = null, parentComponent: ComponentInternalInstance | null = null ): ResolvedSSRBuffer | Promise { return renderComponentVNode(