From a890378b5e9e02b469ee6c1e03540dc896ece122 Mon Sep 17 00:00:00 2001 From: daiwei Date: Wed, 28 May 2025 08:13:15 +0800 Subject: [PATCH 1/7] fix(hydration): handle empty content in Transition appear edge case --- packages/runtime-core/src/hydration.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/runtime-core/src/hydration.ts b/packages/runtime-core/src/hydration.ts index 6ffdbc68de4..771316e6274 100644 --- a/packages/runtime-core/src/hydration.ts +++ b/packages/runtime-core/src/hydration.ts @@ -761,7 +761,8 @@ export function createHydrationFunctions( // replace node const parentNode = oldNode.parentNode if (parentNode) { - parentNode.replaceChild(newNode, oldNode) + if (newNode) parentNode.replaceChild(newNode, oldNode) + else remove(oldNode) } // update vnode From bd7d569fb877fff670340f9df02ac6bffe5ab670 Mon Sep 17 00:00:00 2001 From: daiwei Date: Wed, 28 May 2025 08:18:55 +0800 Subject: [PATCH 2/7] test: add test --- .../runtime-core/__tests__/hydration.spec.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/runtime-core/__tests__/hydration.spec.ts b/packages/runtime-core/__tests__/hydration.spec.ts index 4a9e0fac2b6..bc9b189404d 100644 --- a/packages/runtime-core/__tests__/hydration.spec.ts +++ b/packages/runtime-core/__tests__/hydration.spec.ts @@ -1677,6 +1677,24 @@ describe('SSR hydration', () => { expect(`mismatch`).not.toHaveBeenWarned() }) + // #13394 + test('transition appear work with empty content', () => { + const { vnode, container } = mountWithHydration( + ``, + () => + h( + Transition, + { appear: true }, + { + default: () => null, + }, + ), + ) + expect(container.firstChild).toBe(null) + expect(vnode.el).toBe(container.firstChild) + expect(`mismatch`).not.toHaveBeenWarned() + }) + test('transition appear with v-if', () => { const show = false const { vnode, container } = mountWithHydration( From cd9735dbd3d5fd94f8483caa58990105e1ff0856 Mon Sep 17 00:00:00 2001 From: daiwei Date: Wed, 4 Jun 2025 11:24:33 +0800 Subject: [PATCH 3/7] fix(hydration): handle empty