Open Bug 1444321 Opened 7 years ago Updated 3 years ago

Add an eslint rule to prefer .textContent over .innerText

Categories

(Developer Infrastructure :: Lint and Formatting, enhancement)

3 Branch
enhancement

Tracking

(Not tracked)

People

(Reporter: MattN, Unassigned)

References

()

Details

There are valid reasons to want to read .innerText (e.g. if you want the layout to be taken into account) but in most cases .textContent is sufficient and faster (at least for reads). Since not everyone knows about the differences between innerText and textContent[1] (e.g. that .innerText can cause a reflow) and for consistency, we should give an error for .innerText usage giving a suggestion to use .textContent. Consumers who really care about the different return value can disable the rule for that line. [1] https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent#Differences_from_innerText
Version: Version 3 → 3 Branch
Product: Firefox Build System → Developer Infrastructure
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.