15 lines
443 B
JavaScript
15 lines
443 B
JavaScript
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;
|
|
if (!document.documentElement.contains(el)) return null;
|
|
do {
|
|
if (el.matches(s)) return el;
|
|
el = el.parentElement || el.parentNode;
|
|
} while (el !== null);
|
|
return null;
|
|
};
|