]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(core): use correct parent for v-if toggle
authorEvan You <yyx990803@gmail.com>
Mon, 2 Dec 2019 04:42:14 +0000 (23:42 -0500)
committerEvan You <yyx990803@gmail.com>
Mon, 2 Dec 2019 04:42:14 +0000 (23:42 -0500)
packages/runtime-core/src/renderer.ts

index f666304b14100c2481f1023b37b2b13dbe853074..91de84c72630b3b66d2e577e30d6f0987ed05f1e 100644 (file)
@@ -568,11 +568,13 @@ export function createRenderer<
       patch(
         oldVNode,
         newChildren[i],
-        // in the case of a Fragment, we need to provide the actual parent
-        // of the Fragment itself so it can move its children. In other cases,
-        // the parent container is not actually used so we just pass the
-        // block element here to avoid a DOM parentNode call.
-        oldVNode.type === Fragment
+        // - In the case of a Fragment, we need to provide the actual parent
+        // 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 other cases, the parent container is not actually used so we just
+        // pass the block element here to avoid a DOM parentNode call.
+        oldVNode.type === Fragment || oldVNode.type === Comment
           ? hostParentNode(oldVNode.el!)!
           : fallbackContainer,
         null,