Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 940 Bytes

prefer-dom-node-append.md

File metadata and controls

24 lines (17 loc) · 940 Bytes

Prefer Node#append() over Node#appendChild()

This rule is part of the recommended config.

🔧 This rule is auto-fixable.

Enforces the use of, for example, document.body.append(div); over document.body.appendChild(div); for DOM nodes. There are some advantages of using Node#append(), like the ability to append multiple nodes and to append both DOMString and DOM node objects.

Fail

foo.appendChild(bar);

Pass

foo.append(bar);
foo.append('bar');
foo.append(bar, 'baz');