fix(runtime-core/renderer): fix v-if toggle inside blocks
Should check both branches for parent container access. Fix #604. Close #607.
This commit is contained in:
parent
74baea108a
commit
2e9726e6a2
@ -595,20 +595,22 @@ export function createRenderer<
|
|||||||
) {
|
) {
|
||||||
for (let i = 0; i < newChildren.length; i++) {
|
for (let i = 0; i < newChildren.length; i++) {
|
||||||
const oldVNode = oldChildren[i]
|
const oldVNode = oldChildren[i]
|
||||||
|
const newVNode = newChildren[i]
|
||||||
// Determine the container (parent element) for the patch.
|
// Determine the container (parent element) for the patch.
|
||||||
|
const container =
|
||||||
// - In the case of a Fragment, we need to provide the actual parent
|
// - In the case of a Fragment, we need to provide the actual parent
|
||||||
// of the Fragment itself so it can move its children.
|
// of the Fragment itself so it can move its children.
|
||||||
// - In the case of a Comment, this is likely a v-if toggle, which also
|
|
||||||
// needs the correct parent container.
|
|
||||||
// - In the case of a component, it could contain anything.
|
|
||||||
// In other cases, the parent container is not actually used so we just
|
|
||||||
// pass the block element here to avoid a DOM parentNode call.
|
|
||||||
const container =
|
|
||||||
oldVNode.type === Fragment ||
|
oldVNode.type === Fragment ||
|
||||||
|
// - In the case of Comment nodes, this is likely a v-if toggle, which
|
||||||
|
// also needs the correct parent container.
|
||||||
oldVNode.type === Comment ||
|
oldVNode.type === Comment ||
|
||||||
|
newVNode.type === Comment ||
|
||||||
|
// - In the case of a component, it could contain anything.
|
||||||
oldVNode.shapeFlag & ShapeFlags.COMPONENT
|
oldVNode.shapeFlag & ShapeFlags.COMPONENT
|
||||||
? hostParentNode(oldVNode.el!)!
|
? hostParentNode(oldVNode.el!)!
|
||||||
: fallbackContainer
|
: // In other cases, the parent container is not actually used so we
|
||||||
|
// just pass the block element here to avoid a DOM parentNode call.
|
||||||
|
fallbackContainer
|
||||||
patch(
|
patch(
|
||||||
oldVNode,
|
oldVNode,
|
||||||
newChildren[i],
|
newChildren[i],
|
||||||
|
Loading…
Reference in New Issue
Block a user