Friendiiverse/App/Polyfill/2.Element-remove.js

15 lines
439 B
JavaScript

/**
* ChildNode.remove() polyfill
* https://gomakethings.com/removing-an-element-from-the-dom-the-es6-way/
* @author Chris Ferdinandi
* @license MIT
*/
(function (elem) {
for (var i = 0; i < elem.length; i++) {
if (!window[elem[i]] || 'remove' in window[elem[i]].prototype) continue;
window[elem[i]].prototype.remove = function () {
this.parentNode.removeChild(this);
};
}
})(['Element', 'CharacterData', 'DocumentType']);