Precise DOM morphing
morphing typescript dom
0
fork

Configure Feed

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

Inline hasItemsInCommon

+2 -9
+1 -4
dist/morphlite.js
··· 63 63 else { 64 64 const setA = idMap.get(current); 65 65 const setB = idMap.get(guide); 66 - if (setA && setB && hasItemInCommon(setA, setB)) { 66 + if (setA && setB && [...setA].some((it) => setB.has(it))) { 67 67 return morphNodes(current, guide, idMap, child, parent); 68 68 } 69 69 else if (!nextBestMatch && current.tagName === guide.tagName) { ··· 95 95 current = current.parentElement; 96 96 } 97 97 } 98 - } 99 - function hasItemInCommon(a, b) { 100 - return [...a].some((item) => b.has(item)); 101 98 } 102 99 function isElement(node) { 103 100 return node.nodeType === 1;
+1 -5
src/morphlite.ts
··· 59 59 const setA = idMap.get(current); 60 60 const setB = idMap.get(guide); 61 61 62 - if (setA && setB && hasItemInCommon(setA, setB)) { 62 + if (setA && setB && [...setA].some((it) => setB.has(it))) { 63 63 return morphNodes(current, guide, idMap, child, parent); 64 64 } else if (!nextBestMatch && current.tagName === guide.tagName) { 65 65 nextBestMatch = current; ··· 89 89 current = current.parentElement; 90 90 } 91 91 } 92 - } 93 - 94 - function hasItemInCommon<T>(a: Set<T>, b: Set<T>): boolean { 95 - return [...a].some((item) => b.has(item)); 96 92 } 97 93 98 94 // We cannot use `instanceof` when nodes might be from different documents,