2 * Polyfills for DOM API's
5 // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
6 if (!Element.prototype.matches) {
7 Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
10 // https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Browser_compatibility
11 if (!Element.prototype.closest) {
12 Element.prototype.closest = function (s) {
15 if (!document.documentElement.contains(el)) return null;
17 if (ancestor.matches(s)) return ancestor;
18 ancestor = ancestor.parentElement;
19 } while (ancestor !== null);