tangled
alpha
login
or
join now
yippee.fun
/
morphlex
0
fork
atom
Precise DOM morphing
morphing
typescript
dom
0
fork
atom
overview
issues
pulls
pipelines
Fixes
joel.drapper.me
4 months ago
c2fff671
c60bcf72
+3
-1
1 changed file
expand all
collapse all
unified
split
src
morphlex.ts
+3
-1
src/morphlex.ts
···
59
59
60
60
function moveBefore(parent: ParentNode, node: ChildNode, insertionPoint: ChildNode | null): void {
61
61
if (node === insertionPoint) return
62
62
+
if (node.parentNode === parent && node.nextSibling === insertionPoint) return
62
63
63
63
-
if ("moveBefore" in parent && typeof parent.moveBefore === "function") {
64
64
+
// Use moveBefore when available and the node is already in the same parent
65
65
+
if ("moveBefore" in parent && typeof parent.moveBefore === "function" && node.parentNode === parent) {
64
66
parent.moveBefore(node, insertionPoint)
65
67
} else {
66
68
parent.insertBefore(node, insertionPoint)