Skip to content

Instantly share code, notes, and snippets.

@chrome
Created May 23, 2011 07:30
Show Gist options
  • Save chrome/986355 to your computer and use it in GitHub Desktop.
Save chrome/986355 to your computer and use it in GitHub Desktop.
jquery.role — sizzle edition ;)
jQuery.expr.match['ROLE'] = /\$((?:[\w\u00c0-\uFFFF\-]|\\.)+)/;
jQuery.expr.preFilter['ROLE'] = function( match, curLoop, inplace, result, not, isXML ) {
match = " " + match[1] + " ";
return match;
}
jQuery.expr.filter['ROLE'] = function( elem, match ) {
return (" " + elem.getAttribute('role') + " ").indexOf( match ) > -1;
}
for ( var type in jQuery.expr.match ) {
jQuery.expr.match[ type ] = new RegExp( jQuery.expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
jQuery.expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + jQuery.expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num) {
return "\\" + (num - 0 + 1);
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment