2016-10-17 13:14:46 -04:00
|
|
|
/* global Element */
|
|
|
|
/* eslint-disable consistent-return, max-len */
|
|
|
|
|
|
|
|
Element.prototype.matches = Element.prototype.matches || Element.prototype.msMatchesSelector;
|
2016-10-20 17:18:39 -04:00
|
|
|
|
|
|
|
Element.prototype.closest = function closest(selector, selectedElement = this) {
|
|
|
|
if (!selectedElement) return;
|
|
|
|
return selectedElement.matches(selector) ? selectedElement : Element.prototype.closest(selector, selectedElement.parentElement);
|
|
|
|
};
|