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

Function patchNonKeyedChildren

packages/nerv/src/vdom/patch.ts:168–205  ·  view source on GitHub ↗
(
  parentDom: Element,
  lastChildren,
  nextChildren,
  context: object,
  isSvg: boolean,
  lastLength: number,
  nextLength: number
)

Source from the content-addressed store, hash-verified

166}
167
168function patchNonKeyedChildren (
169 parentDom: Element,
170 lastChildren,
171 nextChildren,
172 context: object,
173 isSvg: boolean,
174 lastLength: number,
175 nextLength: number
176) {
177 const minLength = Math.min(lastLength, nextLength)
178 let i = 0
179 while (i < minLength) {
180 patch(lastChildren[i], nextChildren[i], parentDom, context, isSvg)
181 i++
182 }
183 if (lastLength < nextLength) {
184 for (i = minLength; i < nextLength; i++) {
185 if (parentDom !== null) {
186 const refVnode = lastChildren[i - 1]
187 mountElement(
188 createElement(
189 nextChildren[i],
190 isSvg,
191 context
192 ),
193 parentDom,
194 isValidElement(refVnode) && refVnode.dom != null
195 ? refVnode.dom.nextSibling
196 : null
197 )
198 }
199 }
200 } else if (lastLength > nextLength) {
201 for (i = minLength; i < lastLength; i++) {
202 unmount(lastChildren[i], parentDom)
203 }
204 }
205}
206
207/**
208 *

Callers 1

patchArrayChildrenFunction · 0.85

Calls 5

mountElementFunction · 0.90
isValidElementFunction · 0.90
unmountFunction · 0.90
patchFunction · 0.85
createElementFunction · 0.70

Tested by

no test coverage detected