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);