MCPcopy
hub / github.com/preactjs/preact / innerDiffNode

Function innerDiffNode

test/fixtures/preact.js:234–307  ·  view source on GitHub ↗
(dom, vchildren, context, mountAll, isHydrating)

Source from the content-addressed store, hash-verified

232 return out;
233 }
234 function innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {
235 var j,
236 c,
237 f,
238 vchild,
239 child,
240 originalChildren = dom.childNodes,
241 children = [],
242 keyed = {},
243 keyedLen = 0,
244 min = 0,
245 len = originalChildren.length,
246 childrenLen = 0,
247 vlen = vchildren ? vchildren.length : 0;
248 if (0 !== len)
249 for (var i = 0; i < len; i++) {
250 var _child = originalChildren[i],
251 props = _child.__preactattr_,
252 key =
253 vlen && props
254 ? _child._component
255 ? _child._component.__k
256 : props.key
257 : null;
258 if (null != key) {
259 keyedLen++;
260 keyed[key] = _child;
261 } else if (
262 props ||
263 (void 0 !== _child.splitText
264 ? isHydrating
265 ? _child.nodeValue.trim()
266 : !0
267 : isHydrating)
268 )
269 children[childrenLen++] = _child;
270 }
271 if (0 !== vlen)
272 for (var i = 0; i < vlen; i++) {
273 vchild = vchildren[i];
274 child = null;
275 var key = vchild.key;
276 if (null != key) {
277 if (keyedLen && void 0 !== keyed[key]) {
278 child = keyed[key];
279 keyed[key] = void 0;
280 keyedLen--;
281 }
282 } else if (min < childrenLen)
283 for (j = min; j < childrenLen; j++)
284 if (
285 void 0 !== children[j] &&
286 isSameNodeType((c = children[j]), vchild, isHydrating)
287 ) {
288 child = c;
289 children[j] = void 0;
290 if (j === childrenLen - 1) childrenLen--;
291 if (j === min) min++;

Callers 1

idiffFunction · 0.85

Calls 6

isSameNodeTypeFunction · 0.85
idiffFunction · 0.85
recollectNodeTreeFunction · 0.85
removeNodeFunction · 0.70
appendChildMethod · 0.65
insertBeforeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…