Last active
August 3, 2022 14:45
-
-
Save webshru/1348f8c7ef56663a91eba235a6f68a2e to your computer and use it in GitHub Desktop.
Polyfill. Добавление forEach к NodeList (для IE 11)
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
if (window.NodeList && !NodeList.prototype.forEach) { | |
NodeList.prototype.forEach = function (callback, thisArg) { | |
thisArg = thisArg || window | |
for (var i = 0; i < this.length; i++) { | |
callback.call(thisArg, this[i], i, this) | |
} | |
} | |
} | |
// Или | |
if (window.NodeList && !NodeList.prototype.forEach) { | |
NodeList.prototype.forEach = Array.prototype.forEach | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment