MCPcopy
hub / github.com/vuejs/core / patchBlockChildren

Function patchBlockChildren

packages/runtime-core/src/renderer.ts:975–1017  ·  view source on GitHub ↗
(
    oldChildren,
    newChildren,
    fallbackContainer,
    parentComponent,
    parentSuspense,
    namespace: ElementNamespace,
    slotScopeIds,
  )

Source from the content-addressed store, hash-verified

973
974 // The fast path for blocks.
975 const patchBlockChildren: PatchBlockChildrenFn = (
976 oldChildren,
977 newChildren,
978 fallbackContainer,
979 parentComponent,
980 parentSuspense,
981 namespace: ElementNamespace,
982 slotScopeIds,
983 ) => {
984 for (let i = 0; i < newChildren.length; i++) {
985 const oldVNode = oldChildren[i]
986 const newVNode = newChildren[i]
987 // Determine the container (parent element) for the patch.
988 const container =
989 // oldVNode may be an errored async setup() component inside Suspense
990 // which will not have a mounted element
991 oldVNode.el &&
992 // - In the case of a Fragment, we need to provide the actual parent
993 // of the Fragment itself so it can move its children.
994 (oldVNode.type === Fragment ||
995 // - In the case of different nodes, there is going to be a replacement
996 // which also requires the correct parent container
997 !isSameVNodeType(oldVNode, newVNode) ||
998 // - In the case of a component, it could contain anything.
999 oldVNode.shapeFlag &
1000 (ShapeFlags.COMPONENT | ShapeFlags.TELEPORT | ShapeFlags.SUSPENSE))
1001 ? hostParentNode(oldVNode.el)!
1002 : // In other cases, the parent container is not actually used so we
1003 // just pass the block element here to avoid a DOM parentNode call.
1004 fallbackContainer
1005 patch(
1006 oldVNode,
1007 newVNode,
1008 container,
1009 null,
1010 parentComponent,
1011 parentSuspense,
1012 namespace,
1013 slotScopeIds,
1014 true,
1015 )
1016 }
1017 }
1018
1019 const patchProps = (
1020 el: RendererElement,

Callers 3

patchElementFunction · 0.85
processFragmentFunction · 0.85
processFunction · 0.85

Calls 2

isSameVNodeTypeFunction · 0.90
patchFunction · 0.85

Tested by

no test coverage detected