Skip to content

Latest commit

 

History

History
42 lines (28 loc) · 1.05 KB

prefer-dom-node-text-content.md

File metadata and controls

42 lines (28 loc) · 1.05 KB

Prefer .textContent over .innerText

💼 This rule is enabled in the ✅ recommended config.

💡 This rule is manually fixable by editor 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 = '🦄';