MCPcopy Index your code
hub / github.com/SortableJS/Sortable / swapNodes

Function swapNodes

plugins/Swap/Swap.js:73–88  ·  view source on GitHub ↗
(n1, n2)

Source from the content-addressed store, hash-verified

71
72
73function swapNodes(n1, n2) {
74 let p1 = n1.parentNode,
75 p2 = n2.parentNode,
76 i1, i2;
77
78 if (!p1 || !p2 || p1.isEqualNode(n2) || p2.isEqualNode(n1)) return;
79
80 i1 = index(n1);
81 i2 = index(n2);
82
83 if (p1.isEqualNode(p2) && i1 < i2) {
84 i2++;
85 }
86 p1.insertBefore(n2, p1.children[i1]);
87 p2.insertBefore(n1, p2.children[i2]);
88}
89
90export default SwapPlugin;

Callers 1

dropFunction · 0.70

Calls 1

indexFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…