Skip to content

unicorn/prefer-dom-node-remove Pedantic

What it does

Prefers the use of child.remove() over parentNode.removeChild(child).

Why is this bad?

The DOM function Node#remove() is preferred over the indirect removal of an object with Node#removeChild().

Examples

Examples of incorrect code for this rule:

javascript
parentNode.removeChild(childNode);

Examples of correct code for this rule:

javascript
childNode.remove();

References

Released under the MIT License.