Add support for proposed Element.closest
tmorehouse opened this issue · 4 comments
tmorehouse commented
The Element.closest() method provides a way to search up the dom tree for a node matching a CSS selector
from https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
if (window.Element && !Element.prototype.closest) {
Element.prototype.closest =
function(s) {
var matches = (this.document || this.ownerDocument).querySelectorAll(s),
i,
el = this;
do {
i = matches.length;
while (--i >= 0 && matches.item(i) !== el) {};
} while ((i < 0) && (el = el.parentElement));
return el;
};
}
alexandernanberg commented
I would like to see this added as well!
alexandernanberg commented
@inexorabletash Can you publish a new version now that my PR is merged? :)
inexorabletash commented
Done, thanks for the prompt!
inexorabletash commented
Resolved by b46b5c7