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

Function patchUnkeyedChildren

packages/runtime-core/src/renderer.ts:1744–1801  ·  view source on GitHub ↗
(
    c1: VNode[],
    c2: VNodeArrayChildren,
    container: RendererElement,
    anchor: RendererNode | null,
    parentComponent: ComponentInternalInstance | null,
    parentSuspense: SuspenseBoundary | null,
    namespace: ElementNamespace,
    slotScopeIds: string[] | null,
    optimized: boolean,
  )

Source from the content-addressed store, hash-verified

1742 }
1743
1744 const patchUnkeyedChildren = (
1745 c1: VNode[],
1746 c2: VNodeArrayChildren,
1747 container: RendererElement,
1748 anchor: RendererNode | null,
1749 parentComponent: ComponentInternalInstance | null,
1750 parentSuspense: SuspenseBoundary | null,
1751 namespace: ElementNamespace,
1752 slotScopeIds: string[] | null,
1753 optimized: boolean,
1754 ) => {
1755 c1 = c1 || EMPTY_ARR
1756 c2 = c2 || EMPTY_ARR
1757 const oldLength = c1.length
1758 const newLength = c2.length
1759 const commonLength = Math.min(oldLength, newLength)
1760 let i
1761 for (i = 0; i < commonLength; i++) {
1762 const nextChild = (c2[i] = optimized
1763 ? cloneIfMounted(c2[i] as VNode)
1764 : normalizeVNode(c2[i]))
1765 patch(
1766 c1[i],
1767 nextChild,
1768 container,
1769 null,
1770 parentComponent,
1771 parentSuspense,
1772 namespace,
1773 slotScopeIds,
1774 optimized,
1775 )
1776 }
1777 if (oldLength > newLength) {
1778 // remove old
1779 unmountChildren(
1780 c1,
1781 parentComponent,
1782 parentSuspense,
1783 true,
1784 false,
1785 commonLength,
1786 )
1787 } else {
1788 // mount new
1789 mountChildren(
1790 c2,
1791 container,
1792 anchor,
1793 parentComponent,
1794 parentSuspense,
1795 namespace,
1796 slotScopeIds,
1797 optimized,
1798 commonLength,
1799 )
1800 }
1801 }

Callers 1

patchChildrenFunction · 0.85

Calls 5

cloneIfMountedFunction · 0.90
normalizeVNodeFunction · 0.90
patchFunction · 0.85
unmountChildrenFunction · 0.85
mountChildrenFunction · 0.85

Tested by

no test coverage detected