Skip to content

Commit 2e9726e

Browse files
committed
fix(runtime-core/renderer): fix v-if toggle inside blocks
Should check both branches for parent container access. Fix #604. Close #607.
1 parent 74baea1 commit 2e9726e

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

packages/runtime-core/src/renderer.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -595,20 +595,22 @@ export function createRenderer<
595595
) {
596596
for (let i = 0; i < newChildren.length; i++) {
597597
const oldVNode = oldChildren[i]
598+
const newVNode = newChildren[i]
598599
// Determine the container (parent element) for the patch.
599-
// - In the case of a Fragment, we need to provide the actual parent
600-
// of the Fragment itself so it can move its children.
601-
// - In the case of a Comment, this is likely a v-if toggle, which also
602-
// needs the correct parent container.
603-
// - In the case of a component, it could contain anything.
604-
// In other cases, the parent container is not actually used so we just
605-
// pass the block element here to avoid a DOM parentNode call.
606600
const container =
601+
// - In the case of a Fragment, we need to provide the actual parent
602+
// of the Fragment itself so it can move its children.
607603
oldVNode.type === Fragment ||
604+
// - In the case of Comment nodes, this is likely a v-if toggle, which
605+
// also needs the correct parent container.
608606
oldVNode.type === Comment ||
607+
newVNode.type === Comment ||
608+
// - In the case of a component, it could contain anything.
609609
oldVNode.shapeFlag & ShapeFlags.COMPONENT
610610
? hostParentNode(oldVNode.el!)!
611-
: fallbackContainer
611+
: // In other cases, the parent container is not actually used so we
612+
// just pass the block element here to avoid a DOM parentNode call.
613+
fallbackContainer
612614
patch(
613615
oldVNode,
614616
newChildren[i],

0 commit comments

Comments
 (0)