From a6ae876c54cc218479b8ff3bc09b59070d9b72a6 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Tue, 3 Oct 2023 14:52:00 +0800 Subject: [PATCH 1/2] fix: hydration `__vnode` missing --- packages/runtime-core/src/hydration.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/runtime-core/src/hydration.ts b/packages/runtime-core/src/hydration.ts index 89a00886332..e103b10ce80 100644 --- a/packages/runtime-core/src/hydration.ts +++ b/packages/runtime-core/src/hydration.ts @@ -111,6 +111,17 @@ export function createHydrationFunctions( let domType = node.nodeType vnode.el = node + if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { + Object.defineProperty(node, '__vnode', { + value: vnode, + enumerable: false + }) + Object.defineProperty(node, '__vueParentComponent', { + value: parentComponent, + enumerable: false + }) + } + if (patchFlag === PatchFlags.BAIL) { optimized = false vnode.dynamicChildren = null From 71dcdbc9b2bd5fbf2f910a1828b02caa86d09e03 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Tue, 3 Oct 2023 15:04:28 +0800 Subject: [PATCH 2/2] chore: update --- packages/runtime-core/src/hydration.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/runtime-core/src/hydration.ts b/packages/runtime-core/src/hydration.ts index e103b10ce80..e50ad8ec97e 100644 --- a/packages/runtime-core/src/hydration.ts +++ b/packages/runtime-core/src/hydration.ts @@ -112,14 +112,18 @@ export function createHydrationFunctions( vnode.el = node if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { - Object.defineProperty(node, '__vnode', { - value: vnode, - enumerable: false - }) - Object.defineProperty(node, '__vueParentComponent', { - value: parentComponent, - enumerable: false - }) + if (!('__vnode' in node)) { + Object.defineProperty(node, '__vnode', { + value: vnode, + enumerable: false + }) + } + if (!('__vueParentComponent' in node)) { + Object.defineProperty(node, '__vueParentComponent', { + value: parentComponent, + enumerable: false + }) + } } if (patchFlag === PatchFlags.BAIL) {