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

This comment has been minimized.

Copy link

@saltnpixels saltnpixels commented Jul 3, 2018

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

@Herokid

This comment has been minimized.

Copy link

@Herokid Herokid commented Sep 18, 2018

Nice! (:

@pedroapfilho

This comment has been minimized.

Copy link

@pedroapfilho pedroapfilho commented Apr 18, 2019

You just saved me, thanks!

@bbdf-design

This comment has been minimized.

Copy link

@bbdf-design bbdf-design commented Apr 30, 2019

Great, thanks!

@Canopix

This comment has been minimized.

Copy link

@Canopix Canopix commented Aug 22, 2019

Thanks!

@kingsley00

This comment has been minimized.

Copy link

@kingsley00 kingsley00 commented Oct 9, 2019

Thank you

@herico

This comment has been minimized.

Copy link

@herico herico commented Oct 21, 2019

Thanks :)

@dafoxuk

This comment has been minimized.

Copy link

@dafoxuk dafoxuk commented Oct 28, 2019

Nice and clean polyfill - thank ya!

@Abdull

This comment has been minimized.

Copy link

@Abdull 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

This comment has been minimized.

Copy link

@rornfdlek rornfdlek commented Dec 27, 2019

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

@LianSheng197

This comment has been minimized.

Copy link

@LianSheng197 LianSheng197 commented Feb 20, 2020

Thanks!! It's very simple and work!

@dimitristahos

This comment has been minimized.

Copy link

@dimitristahos dimitristahos commented Apr 2, 2020

🍺🍺🍺🍺🤘🤘🤘🤘

@ivan-markin

This comment has been minimized.

Copy link

@ivan-markin ivan-markin commented May 17, 2020

🙏🙏🙏

@Gaarmy

This comment has been minimized.

Copy link

@Gaarmy Gaarmy commented May 20, 2020

Thank you so much!

@PaliyStepan

This comment has been minimized.

Copy link

@PaliyStepan PaliyStepan commented Sep 8, 2020

thanks dude! u saved me )

@kflogerzi

This comment has been minimized.

Copy link

@kflogerzi kflogerzi commented Nov 12, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.