Precise DOM morphing
morphing typescript dom
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Optimise morphChildNodes

+11 -6
+5 -3
dist/morphlex.js
··· 35 35 elem.value = guide.value; 36 36 } 37 37 function morphChildNodes(elem, guide, idMap) { 38 - for (let i = 0; i < guide.childNodes.length; i++) { 39 - const childA = [...elem.childNodes].at(i); 40 - const childB = [...guide.childNodes].at(i); 38 + const childNodes = [...elem.childNodes]; 39 + const guideChildNodes = [...guide.childNodes]; 40 + for (let i = 0; i < guideChildNodes.length; i++) { 41 + const childA = childNodes.at(i); 42 + const childB = guideChildNodes.at(i); 41 43 if (childA && childB) 42 44 morphChildNode(childA, childB, idMap, elem); 43 45 else if (childB)
+6 -3
src/morphlex.ts
··· 33 33 } 34 34 35 35 function morphChildNodes(elem: Element, guide: Element, idMap: IdMap): void { 36 - for (let i = 0; i < guide.childNodes.length; i++) { 37 - const childA = [...elem.childNodes].at(i); 38 - const childB = [...guide.childNodes].at(i); 36 + const childNodes = [...elem.childNodes]; 37 + const guideChildNodes = [...guide.childNodes]; 38 + 39 + for (let i = 0; i < guideChildNodes.length; i++) { 40 + const childA = childNodes.at(i); 41 + const childB = guideChildNodes.at(i); 39 42 40 43 if (childA && childB) morphChildNode(childA, childB, idMap, elem); 41 44 else if (childB) elem.appendChild(childB.cloneNode(true));