MCPcopy
hub / github.com/NervJS/nerv / patchArrayChildren

Function patchArrayChildren

packages/nerv/src/vdom/patch.ts:101–142  ·  view source on GitHub ↗
(
  parentDom: Element,
  lastChildren,
  nextChildren,
  context: object,
  isSvg: boolean
)

Source from the content-addressed store, hash-verified

99}
100
101function patchArrayChildren (
102 parentDom: Element,
103 lastChildren,
104 nextChildren,
105 context: object,
106 isSvg: boolean
107) {
108 const lastLength = lastChildren.length
109 const nextLength = nextChildren.length
110 if (lastLength === 0) {
111 if (nextLength > 0) {
112 for (let i = 0; i < nextLength; i++) {
113 mountChild(nextChildren[i], parentDom, context, isSvg)
114 }
115 }
116 } else if (nextLength === 0) {
117 unmountChildren(lastChildren)
118 parentDom.textContent = ''
119 } else {
120 if (isKeyed(lastChildren, nextChildren)) {
121 patchKeyedChildren(
122 lastChildren,
123 nextChildren,
124 parentDom,
125 context,
126 isSvg,
127 lastLength,
128 nextLength
129 )
130 } else {
131 patchNonKeyedChildren(
132 parentDom,
133 lastChildren,
134 nextChildren,
135 context,
136 isSvg,
137 lastLength,
138 nextLength
139 )
140 }
141 }
142}
143
144export function patchChildren (
145 parentDom: Element,

Callers 2

patchFunction · 0.85
patchChildrenFunction · 0.85

Calls 5

mountChildFunction · 0.90
unmountChildrenFunction · 0.90
isKeyedFunction · 0.85
patchKeyedChildrenFunction · 0.85
patchNonKeyedChildrenFunction · 0.85

Tested by

no test coverage detected