Skip to content

Latest commit

 

History

History
21 lines (13 loc) · 572 Bytes

prefer-node-remove.md

File metadata and controls

21 lines (13 loc) · 572 Bytes

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

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

This rule is fixable.

Fail

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

Pass

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