Skip to content

Instantly share code, notes, and snippets.

@MTco
Created January 9, 2021 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MTco/23c94affcd4ecd5d42b06a2155285078 to your computer and use it in GitHub Desktop.
Save MTco/23c94affcd4ecd5d42b06a2155285078 to your computer and use it in GitHub Desktop.
// 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