Skip to content

Latest commit

 

History

History
42 lines (29 loc) · 1.04 KB

prefer-dom-node-text-content.md

File metadata and controls

42 lines (29 loc) · 1.04 KB

Prefer .textContent over .innerText

This rule is part of the recommended config.

💡 This rule provides suggestions.

Enforces the use of .textContent over .innerText for DOM nodes.

There are some advantages of using .textContent, like performance and more predictable behavior when updating it.

Note that there are differences between them.

Fail

const text = foo.innerText;
const {innerText} = foo;
foo.innerText = '🦄';

Pass

const text = foo.textContent;
const {textContent} = foo;
foo.textContent = '🦄';