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

Function processFragment

packages/runtime-core/src/renderer.ts:1057–1163  ·  view source on GitHub ↗
(
    n1: VNode | null,
    n2: VNode,
    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

1055 }
1056
1057 const processFragment = (
1058 n1: VNode | null,
1059 n2: VNode,
1060 container: RendererElement,
1061 anchor: RendererNode | null,
1062 parentComponent: ComponentInternalInstance | null,
1063 parentSuspense: SuspenseBoundary | null,
1064 namespace: ElementNamespace,
1065 slotScopeIds: string[] | null,
1066 optimized: boolean,
1067 ) => {
1068 const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''))!
1069 const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''))!
1070
1071 let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2
1072
1073 if (
1074 __DEV__ &&
1075 // #5523 dev root fragment may inherit directives
1076 (isHmrUpdating || patchFlag & PatchFlags.DEV_ROOT_FRAGMENT)
1077 ) {
1078 // HMR updated / Dev root fragment (w/ comments), force full diff
1079 patchFlag = 0
1080 optimized = false
1081 dynamicChildren = null
1082 }
1083
1084 // check if this is a slot fragment with :slotted scope ids
1085 if (fragmentSlotScopeIds) {
1086 slotScopeIds = slotScopeIds
1087 ? slotScopeIds.concat(fragmentSlotScopeIds)
1088 : fragmentSlotScopeIds
1089 }
1090
1091 if (n1 == null) {
1092 hostInsert(fragmentStartAnchor, container, anchor)
1093 hostInsert(fragmentEndAnchor, container, anchor)
1094 // a fragment can only have array children
1095 // since they are either generated by the compiler, or implicitly created
1096 // from arrays.
1097 mountChildren(
1098 // #10007
1099 // such fragment like `<></>` will be compiled into
1100 // a fragment which doesn't have a children.
1101 // In this case fallback to an empty array
1102 (n2.children || []) as VNodeArrayChildren,
1103 container,
1104 fragmentEndAnchor,
1105 parentComponent,
1106 parentSuspense,
1107 namespace,
1108 slotScopeIds,
1109 optimized,
1110 )
1111 } else {
1112 if (
1113 patchFlag > 0 &&
1114 patchFlag & PatchFlags.STABLE_FRAGMENT &&

Callers 1

patchFunction · 0.85

Calls 4

mountChildrenFunction · 0.85
patchBlockChildrenFunction · 0.85
traverseStaticChildrenFunction · 0.85
patchChildrenFunction · 0.85

Tested by

no test coverage detected