Created
August 15, 2012 11:06
-
-
Save rudiedirkx/3359186 to your computer and use it in GitHub Desktop.
JS polyfill for Element.matchesSelector
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.prototype.matchesSelector || (Element.prototype.matchesSelector = Element.prototype.webkitMatchesSelector || Element.prototype.mozMatchesSelector || function(selecta) { | |
var els = document.querySelectorAll(selecta); | |
for ( var i=0, L=els.length; i<L; i++ ) { | |
if ( els[i] == this ) { | |
return true; | |
} | |
} | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment