Swapping the place of two nodes in a document is not that hard but it requires more code than one would expect. It would be nice if we could add this MS extension. Here is a pure JS implementation: Node.prototype.swapNode = function(that) { var nextSibling = this.nextSibling; if (nextSibling == that) { that.swapNode(this); return; } var thisParent = this.parentNode; that.parentNode.replaceChild(this, that); thisParent.insertBefore(that, nextSibling); };
They got you covered baby, check out document.documentFragment Here's a handy link to see if it will meet your needs. http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-1004215813 That node swap is kooky man, can't somebody dump this ticket?
swapNode was IE only and it was changed with "replaceChild". https://quirksmode.org/dom/core/ Even below test page - give "swapNode gave an error" across all browsers (Chrome Canary 106, Firefox Nightly 105 and Safari 15.6). https://quirksmode.org/dom/core/microsoft.html Only found this reference about it in Webkit Github: https://github.com/WebKit/WebKit/blob/8afe31a018b11741abdf9b4d5bb973d7c1d9ff05/JSTests/ChakraCore/test/Basics/DomProperties.js#L3414 I am going to mark this as "RESOLVED WONTFIX". If I am incorrect, please mark accordingly. Thanks!