Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

封装remove child.remove()销毁自身 #113

Open
Sunny-117 opened this issue Nov 3, 2022 · 1 comment
Open

封装remove child.remove()销毁自身 #113

Sunny-117 opened this issue Nov 3, 2022 · 1 comment

Comments

@Sunny-117
Copy link
Owner

No description provided.

@CwRv07
Copy link
Contributor

CwRv07 commented Mar 8, 2023

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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants