Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Polyfill for IE11 missing NodeList.forEach
if ('NodeList' in window && !NodeList.prototype.forEach) {
console.info('polyfill for IE11');
NodeList.prototype.forEach = function (callback, thisArg) {
thisArg = thisArg || window;
for (var i = 0; i < this.length; i++) {
callback.call(thisArg, this[i], i, this);
}
};
}
@saltnpixels
Copy link

saltnpixels commented Jul 3, 2018

Thank you! Seems babel doesn't take care of this.

@Herokid
Copy link

Herokid commented Sep 18, 2018

Nice! (:

@pedroapfilho
Copy link

pedroapfilho commented Apr 18, 2019

You just saved me, thanks!

@bbdf-design
Copy link

bbdf-design commented Apr 30, 2019

Great, thanks!

@Canopix
Copy link

Canopix commented Aug 22, 2019

Thanks!

@kingsley00
Copy link

kingsley00 commented Oct 9, 2019

Thank you

@herico
Copy link

herico commented Oct 21, 2019

Thanks :)

@dafoxuk
Copy link

dafoxuk commented Oct 28, 2019

Nice and clean polyfill - thank ya!

@Abdull
Copy link

Abdull commented Nov 15, 2019

//Polyfill for HTMLCollection.forEach
if ('HTMLCollection' in window && !HTMLCollection.prototype.forEach) {
  console.info('polyfill HTMLCollection for IE11');
  HTMLCollection.prototype.forEach = function (callback, thisArg) {
    thisArg = thisArg || window;
    for (var i = 0; i < this.length; i++) {
      callback.call(thisArg, this[i], i, this);
    }
  };
}

@rornfdlek
Copy link

rornfdlek commented Dec 27, 2019

You saved me!! Thank you so much!!!!!

@LianSheng197
Copy link

LianSheng197 commented Feb 20, 2020

Thanks!! It's very simple and work!

@dimitristahos
Copy link

dimitristahos commented Apr 2, 2020

🍺🍺🍺🍺🤘🤘🤘🤘

@ivan-markin
Copy link

ivan-markin commented May 17, 2020

🙏🙏🙏

@Gaarmy
Copy link

Gaarmy commented May 20, 2020

Thank you so much!

@PaliyStepan
Copy link

PaliyStepan commented Sep 8, 2020

thanks dude! u saved me )

@kflogdev
Copy link

kflogdev commented Nov 12, 2020

After searching high and low, this finally worked (specifically for Sharepoint SPFx)! Thank you!

@oxyyyyy
Copy link

oxyyyyy commented Dec 23, 2020

Thanks
Anybody knows why Babel ignores .forEach() ?

@darkcris1
Copy link

darkcris1 commented Jan 27, 2021

Babel

Thanks
Anybody knows why Babel ignores .forEach() ?

Because babel doesn't care of polyfills. It only focus on transpiling your code

@oxyyyyy
Copy link

oxyyyyy commented Feb 16, 2021

Babel

Thanks
Anybody knows why Babel ignores .forEach() ?

Because babel doesn't care of polyfills. It only focus on transpiling your code

Oh, for sure..
thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment