Precise DOM morphing
morphing typescript dom

Fixes

+3 -1
+3 -1
src/morphlex.ts
··· 59 60 function moveBefore(parent: ParentNode, node: ChildNode, insertionPoint: ChildNode | null): void { 61 if (node === insertionPoint) return 62 63 - if ("moveBefore" in parent && typeof parent.moveBefore === "function") { 64 parent.moveBefore(node, insertionPoint) 65 } else { 66 parent.insertBefore(node, insertionPoint)
··· 59 60 function moveBefore(parent: ParentNode, node: ChildNode, insertionPoint: ChildNode | null): void { 61 if (node === insertionPoint) return 62 + if (node.parentNode === parent && node.nextSibling === insertionPoint) return 63 64 + // Use moveBefore when available and the node is already in the same parent 65 + if ("moveBefore" in parent && typeof parent.moveBefore === "function" && node.parentNode === parent) { 66 parent.moveBefore(node, insertionPoint) 67 } else { 68 parent.insertBefore(node, insertionPoint)