summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/commons/polyfills/nodelist.js
blob: 3a9111e64f8814ead9c955b4206a188b21f23aa9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
 * Polyfill
 * @what NodeList.forEach
 * @why To align browser support
 * @browsers Internet Explorer 11
 * @see https://caniuse.com/#feat=mdn-api_nodelist_foreach
 */
if (window.NodeList && !NodeList.prototype.forEach) {
  NodeList.prototype.forEach = function forEach(callback, thisArg = window) {
    for (let i = 0; i < this.length; i += 1) {
      callback.call(thisArg, this[i], i, this);
    }
  };
}