Add replaceNode switch (#141)

* Add replaceNode switch

* Add test for replaceNode()

* Update TS definitions
This commit was merged in pull request #141.
This commit is contained in:
BehindTheMath
2018-03-20 10:52:55 -04:00
committed by GitHub
parent 5e41a32cf4
commit 75eb83dbc2
4 changed files with 36 additions and 2 deletions

View File

@@ -26,6 +26,12 @@ module.exports = {
this.onSwitch()
},
// Equivalent to outerHTML(), but doesn't require switchElementsAlt() for <head> and <body>
replaceNode: function(oldEl, newEl) {
oldEl.parentNode.replaceChild(newEl, oldEl)
this.onSwitch()
},
sideBySide: function(oldEl, newEl, options, switchOptions) {
var forEach = Array.prototype.forEach
var elsToRemove = []