封装remove child.remove()销毁自身
Sunny-117 opened this issue · comments
封装remove child.remove()销毁自身
Element.prototype._remove = function () {
if (!(this instanceof Element) || this.tagName === 'HTML') {
throw new TypeError(`${this} is not an element or cannot be removed`);
}
const el = this;
el.parentElement.removeChild(el);
}