Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 900 Bytes

prefer-dom-node-remove.md

File metadata and controls

21 lines (14 loc) · 900 Bytes

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