Explorar el Código

perf: avoid parentNode call when dynamic child is not a Fragment

Evan You hace 6 años
padre
commit
1b06b3c424
Se han modificado 1 ficheros con 5 adiciones y 1 borrados
  1. 5 1
      packages/runtime-core/src/createRenderer.ts

+ 5 - 1
packages/runtime-core/src/createRenderer.ts

@@ -503,7 +503,11 @@ export function createRenderer<
         patch(
           oldVNode,
           dynamicChildren[i],
-          hostParentNode(oldVNode.el!)!,
+          // 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 ? hostParentNode(oldVNode.el!)! : el,
           null,
           parentComponent,
           parentSuspense,