From b804e6f9da92ecb00d415b145664d750aafc5896 Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Sat, 11 Nov 2023 10:48:56 +0100 Subject: [PATCH] fixies --- packages/core/src/index.js | 4 ++++ packages/core/src/runtime/vnode.js | 15 +++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/core/src/index.js b/packages/core/src/index.js index 6c80ef4e..ca319983 100644 --- a/packages/core/src/index.js +++ b/packages/core/src/index.js @@ -70,6 +70,9 @@ function replaceComponent(OldType, NewType, resetHookState) { vnode[VNODE_COMPONENT].context ); + newInst['__v'] = vnode; + oldInst['__v'] = vnode; + vnode[VNODE_COMPONENT] = newInst; // copy old properties onto the new instance. // - Objects (including refs) in the new instance are updated with their old values @@ -96,6 +99,7 @@ function replaceComponent(OldType, NewType, resetHookState) { } catch (e) { /* Functional component */ vnode[VNODE_COMPONENT].constructor = NewType; + vnode[VNODE_COMPONENT].__v = vnode; } if (resetHookState) { diff --git a/packages/core/src/runtime/vnode.js b/packages/core/src/runtime/vnode.js index 01c77d51..e86a8b13 100644 --- a/packages/core/src/runtime/vnode.js +++ b/packages/core/src/runtime/vnode.js @@ -31,13 +31,16 @@ options.vnode = vnode => { } vnode.type = foundType; - if ( - vnode[VNODE_COMPONENT] && - 'prototype' in vnode.type && - vnode.type.prototype.render - ) { - vnode[VNODE_COMPONENT].constructor = vnode.type; + if (vnode[VNODE_COMPONENT]) { + vnode[VNODE_COMPONENT].__v = vnode; + if ( + 'prototype' in vnode.type && + vnode.type.prototype.render + ) { + vnode[VNODE_COMPONENT].constructor = vnode.type; + } } + } if (oldVnode) oldVnode(vnode);