]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(renderer): should also use latest parent node when patching block child components
authorEvan You <yyx990803@gmail.com>
Wed, 18 Dec 2019 22:09:28 +0000 (17:09 -0500)
committerEvan You <yyx990803@gmail.com>
Wed, 18 Dec 2019 22:09:28 +0000 (17:09 -0500)
packages/runtime-core/src/renderer.ts

index 133a21c2461e7ada1525cd28531fa190d5a8c127..9fc0ebb681eb5d266a3599396be1bc6bc0375c3c 100644 (file)
@@ -594,21 +594,24 @@ export function createRenderer<
   ) {
     for (let i = 0; i < newChildren.length; i++) {
       const oldVNode = oldChildren[i]
-      if (!oldVNode) {
-        debugger
-      }
+      // Determine the container (parent element) for the patch.
+      // - 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 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 === Comment ||
+        oldVNode.shapeFlag & ShapeFlags.COMPONENT
+          ? hostParentNode(oldVNode.el!)!
+          : fallbackContainer
       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 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,
+        container,
         null,
         parentComponent,
         parentSuspense,