From cd659fc86f74741987bacc351f0d94ef3b80a1ca Mon Sep 17 00:00:00 2001 From: edison Date: Tue, 10 May 2022 18:35:34 +0800 Subject: [PATCH] fix(ssr): should de-optimize on vnode with PatchFlags.BAIL (#4818) fix #4679 fix #5771 --- packages/runtime-core/src/hydration.ts | 7 ++++++- packages/runtime-dom/src/apiCustomElement.ts | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/runtime-core/src/hydration.ts b/packages/runtime-core/src/hydration.ts index ef66f0d3fe6..3d86f0f2494 100644 --- a/packages/runtime-core/src/hydration.ts +++ b/packages/runtime-core/src/hydration.ts @@ -97,10 +97,15 @@ export function createHydrationFunctions( isFragmentStart ) - const { type, ref, shapeFlag } = vnode + const { type, ref, shapeFlag, patchFlag } = vnode const domType = node.nodeType vnode.el = node + if (patchFlag === PatchFlags.BAIL) { + optimized = false + vnode.dynamicChildren = null + } + let nextNode: Node | null = null switch (type) { case Text: diff --git a/packages/runtime-dom/src/apiCustomElement.ts b/packages/runtime-dom/src/apiCustomElement.ts index 059fcac16f1..eabe83b6b9f 100644 --- a/packages/runtime-dom/src/apiCustomElement.ts +++ b/packages/runtime-dom/src/apiCustomElement.ts @@ -122,13 +122,13 @@ export function defineCustomElement(options: { export function defineCustomElement( options: any, - hydate?: RootHydrateFunction + hydrate?: RootHydrateFunction ): VueElementConstructor { const Comp = defineComponent(options as any) class VueCustomElement extends VueElement { static def = Comp constructor(initialProps?: Record) { - super(Comp, initialProps, hydate) + super(Comp, initialProps, hydrate) } }