소스 검색

fix(core): use correct parent for v-if toggle

Evan You 6 년 전
부모
커밋
24f6d63c6a
1개의 변경된 파일7개의 추가작업 그리고 5개의 파일을 삭제
  1. 7 5
      packages/runtime-core/src/renderer.ts

+ 7 - 5
packages/runtime-core/src/renderer.ts

@@ -568,11 +568,13 @@ export function createRenderer<
       patch(
       patch(
         oldVNode,
         oldVNode,
         newChildren[i],
         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!)!
           ? hostParentNode(oldVNode.el!)!
           : fallbackContainer,
           : fallbackContainer,
         null,
         null,