Files
remark42/frontend/app/common/closest-polyfill.ts
T
Misha VyrtsevandUmputun 9fbdff106d Update deps 2019 09 (#439)
* update minor deps

* update minor deps

* update major deps

* fix eslint warnings
2019-09-29 14:09:00 -05:00

18 lines
596 B
TypeScript

if (!Element.prototype.matches) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Element.prototype.matches = (Element.prototype as any).msMatchesSelector || Element.prototype.webkitMatchesSelector;
}
if (!Element.prototype.closest) {
Element.prototype.closest = function(s: string) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-this-alias
let el: any = this;
do {
if (el.matches(s)) return el;
el = el.parentElement || el.parentNode;
} while (el !== null && el.nodeType === 1);
return null;
};
}