Skip to content

A polyfill for .innerText, since it's nonstandard so Firefox does not include it.

License

Notifications You must be signed in to change notification settings

tenfold/innerText-polyfill

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTMLElement#innerText polyfill

I am well aware that innerText is nonstandard, and should generally be avoided. However, I've ran into a few situations where textContent is utterly useless, and innerHTML opens up the usual issues that arise with embedding user-supplied HTML.

So, I decided to make a polyfill for innerText, even though it probably shouldn't be used if there's an alternative available.

IE has had innerText for a long time, so we basically only need a polyfill for Firefox. This means we can take advantage of Selection. You can find out more information about Selection on the Mozilla Developer Network (MDN).

The code's pretty self explanatory, and commented, so read that if you want to figure out how it works.

About

A polyfill for .innerText, since it's nonstandard so Firefox does not include it.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 52.5%
  • HTML 47.5%