refactor(ssr): make hydration logic tree-shakeable

This commit is contained in:
Evan You
2020-02-14 01:30:08 -05:00
parent 112d8f7d86
commit 167f8241bd
5 changed files with 121 additions and 41 deletions

View File

@@ -91,7 +91,7 @@ export type CreateAppFunction<HostElement> = (
export function createAppAPI<HostNode, HostElement>(
render: RootRenderFunction<HostNode, HostElement>,
hydrate: (vnode: VNode, container: Element) => void
hydrate?: (vnode: VNode, container: Element) => void
): CreateAppFunction<HostElement> {
return function createApp(rootComponent: Component, rootProps = null) {
if (rootProps != null && !isObject(rootProps)) {
@@ -200,7 +200,7 @@ export function createAppAPI<HostNode, HostElement>(
}
}
if (isHydrate) {
if (isHydrate && hydrate) {
hydrate(vnode, rootContainer as any)
} else {
render(vnode, rootContainer)