Skip to content

Instantly share code, notes, and snippets.

@yckart
Last active December 19, 2015 09:19
Show Gist options
  • Save yckart/5932173 to your computer and use it in GitHub Desktop.
Save yckart/5932173 to your computer and use it in GitHub Desktop.
// jonathantneal's polyfill for matchesSelector
if (this.Element) function(ElementPrototype) {
ElementPrototype.matches = ElementPrototype.matchesSelector =
ElementPrototype.matchesSelector ||
ElementPrototype.webkitMatchesSelector ||
ElementPrototype.mozMatchesSelector ||
ElementPrototype.msMatchesSelector ||
ElementPrototype.oMatchesSelector ||
function (selector) {
var nodes = (this.parentNode || this.document).querySelectorAll(selector), i = -1;
while (nodes[++i] && nodes[i] !== this);
return !!nodes[i];
};
}(Element.prototype);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment