Created
January 27, 2021 10:08
-
-
Save darkcris1/414343a53845eff5decee7fd458b6b75 to your computer and use it in GitHub Desktop.
NodeList forEach polyfill for IE 11 | + HTMLCollection.forEach
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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