summaryrefslogtreecommitdiffstats
path: root/web_src/js/polyfills.js
blob: 0063b6d25324748092ebe734ebfc03fea4afbf0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// compat: IE11
if (!Element.prototype.matches) {
  Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
}

// compat: IE11
if (!Element.prototype.closest) {
  Element.prototype.closest = function (s) {
    let el = this;

    do {
      if (el.matches(s)) return el;
      el = el.parentElement || el.parentNode;
    } while (el !== null && el.nodeType === 1);
    return null;
  };
}