Skip to content

Files

Latest commit

 

History

History
19 lines (13 loc) · 521 Bytes

prefer-dom-node-text-content.md

File metadata and controls

19 lines (13 loc) · 521 Bytes

Pattern: Use of innerText property

Issue: -

Description

The textContent property is preferred over innerText as it has better performance (doesn't trigger layout calculations), works on all Node objects (not just HTMLElement), and has broader browser support. innerText is non-standard and not available in some browsers like Firefox.

Examples

Example of incorrect code:

const text = foo.innerText;

Example of correct code:

const text = foo.textContent;