mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-31 08:02:42 +01:00
20 lines
563 B
JavaScript
20 lines
563 B
JavaScript
|
/**
|
||
|
* Polyfills for DOM API's
|
||
|
*/
|
||
|
|
||
|
if (!Element.prototype.matches) {
|
||
|
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
||
|
}
|
||
|
|
||
|
if (!Element.prototype.closest) {
|
||
|
Element.prototype.closest = function (s) {
|
||
|
var el = this;
|
||
|
var ancestor = this;
|
||
|
if (!document.documentElement.contains(el)) return null;
|
||
|
do {
|
||
|
if (ancestor.matches(s)) return ancestor;
|
||
|
ancestor = ancestor.parentElement;
|
||
|
} while (ancestor !== null);
|
||
|
return null;
|
||
|
};
|
||
|
}
|