Forked from jonathantneal/matchesSelector.polyfill.js
Last active
August 29, 2015 14:21
-
-
Save yuchuanxi/3add5e7bec8730e57fcd to your computer and use it in GitHub Desktop.
Element matches Polyfill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Element && !Element.prototype.matches && (function(proto) { | |
proto.matches = proto.matchesSelector || | |
proto.mozMatchesSelector || | |
proto.msMatchesSelector || | |
proto.oMatchesSelector || | |
proto.webkitMatchesSelector || | |
function (selector) { | |
var node = this, nodes = (node.parentNode || node.document || element.ownerDocument) | |
.querySelectorAll(selector), i = -1; | |
while (nodes[ ++i ] && nodes[i] !== node); | |
return !!nodes[i]; | |
}; | |
})(Element.prototype); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment