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

Function patchChildren

packages/runtime-core/src/renderer.ts:1642–1742  ·  view source on GitHub ↗
(
    n1,
    n2,
    container,
    anchor,
    parentComponent,
    parentSuspense,
    namespace: ElementNamespace,
    slotScopeIds,
    optimized = false,
  )

Source from the content-addressed store, hash-verified

1640 }
1641
1642 const patchChildren: PatchChildrenFn = (
1643 n1,
1644 n2,
1645 container,
1646 anchor,
1647 parentComponent,
1648 parentSuspense,
1649 namespace: ElementNamespace,
1650 slotScopeIds,
1651 optimized = false,
1652 ) => {
1653 const c1 = n1 && n1.children
1654 const prevShapeFlag = n1 ? n1.shapeFlag : 0
1655 const c2 = n2.children
1656
1657 const { patchFlag, shapeFlag } = n2
1658 // fast path
1659 if (patchFlag > 0) {
1660 if (patchFlag & PatchFlags.KEYED_FRAGMENT) {
1661 // this could be either fully-keyed or mixed (some keyed some not)
1662 // presence of patchFlag means children are guaranteed to be arrays
1663 patchKeyedChildren(
1664 c1 as VNode[],
1665 c2 as VNodeArrayChildren,
1666 container,
1667 anchor,
1668 parentComponent,
1669 parentSuspense,
1670 namespace,
1671 slotScopeIds,
1672 optimized,
1673 )
1674 return
1675 } else if (patchFlag & PatchFlags.UNKEYED_FRAGMENT) {
1676 // unkeyed
1677 patchUnkeyedChildren(
1678 c1 as VNode[],
1679 c2 as VNodeArrayChildren,
1680 container,
1681 anchor,
1682 parentComponent,
1683 parentSuspense,
1684 namespace,
1685 slotScopeIds,
1686 optimized,
1687 )
1688 return
1689 }
1690 }
1691
1692 // children has 3 possibilities: text, array or no children.
1693 if (shapeFlag & ShapeFlags.TEXT_CHILDREN) {
1694 // text children fast path
1695 if (prevShapeFlag & ShapeFlags.ARRAY_CHILDREN) {
1696 unmountChildren(c1 as VNode[], parentComponent, parentSuspense)
1697 }
1698 if (c2 !== c1) {
1699 hostSetElementText(container, c2 as string)

Callers 3

patchElementFunction · 0.85
processFragmentFunction · 0.85
processFunction · 0.85

Calls 4

patchKeyedChildrenFunction · 0.85
patchUnkeyedChildrenFunction · 0.85
unmountChildrenFunction · 0.85
mountChildrenFunction · 0.85

Tested by

no test coverage detected