]> BookStack Code Mirror - bookstack/blob - resources/assets/js/dom-polyfills.js
add missing icon, fix name conventions
[bookstack] / resources / assets / js / dom-polyfills.js
1 /**
2  * Polyfills for DOM API's
3  */
4
5 if (!Element.prototype.matches) {
6     Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
7 }
8
9 if (!Element.prototype.closest) {
10     Element.prototype.closest = function (s) {
11         var el = this;
12         var ancestor = this;
13         if (!document.documentElement.contains(el)) return null;
14         do {
15             if (ancestor.matches(s)) return ancestor;
16             ancestor = ancestor.parentElement;
17         } while (ancestor !== null);
18         return null;
19     };
20 }