imagitama / nodelist-foreach-polyfill

Polyfill for NodeList.forEach
ISC License
27 stars 4 forks source link

Polyfill should include check to prevent overwriting native implementation on modern browsers #1

Closed reesscot closed 7 years ago

reesscot commented 7 years ago

Polyfill is missing the if check listed on MDN:

if (window.NodeList && !NodeList.prototype.forEach) {
    NodeList.prototype.forEach = function (callback, argument) {
        argument = argument || window;
        for (var i = 0; i < this.length; i++) {
            callback.call(argument, this[i], i, this);
        }
    };
}
imagitama commented 7 years ago

Released in version 1.1.0 (published to NPM)