Skip to content

Instantly share code, notes, and snippets.

@darkcris1
Created January 27, 2021 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darkcris1/414343a53845eff5decee7fd458b6b75 to your computer and use it in GitHub Desktop.
Save darkcris1/414343a53845eff5decee7fd458b6b75 to your computer and use it in GitHub Desktop.
NodeList forEach polyfill for IE 11 | + HTMLCollection.forEach
// You can exclude this if you will not use it
HTMLCollection.prototype.forEach = function (callback, thisArg) {
Array.prototype.forEach.call(this, callback, thisArg || window)
}
if ('NodeList' in window && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = function (callback, thisArg) {
Array.prototype.forEach.call(this, callback, thisArg || window)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment