Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 1.01 KB

prefer-dom-node-remove.md

File metadata and controls

24 lines (17 loc) · 1.01 KB

Prefer childNode.remove() over parentNode.removeChild(childNode)

This rule is part of the recommended config.

🔧💡 This rule is auto-fixable and provides suggestions.

Enforces the use of, for example, child.remove(); over child.parentNode.removeChild(child);. The DOM function Node#remove() is preferred over the indirect removal of an object with Node#removeChild().

Fail

parentNode.removeChild(foo);
parentNode.removeChild(this);

Pass

foo.remove();
this.remove();