Created
January 9, 2021 17:45
-
-
Save MTco/23c94affcd4ecd5d42b06a2155285078 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// via: https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove | |
// from:https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md | |
(function (arr) { | |
arr.forEach(function (item) { | |
if (item.hasOwnProperty('remove')) { | |
return; | |
} | |
Object.defineProperty(item, 'remove', { | |
configurable: true, | |
enumerable: true, | |
writable: true, | |
value: function remove() { | |
this.parentNode.removeChild(this); | |
} | |
}); | |
}); | |
})([Element.prototype, CharacterData.prototype, DocumentType.prototype]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment