Fix bug #2773, jQuery.fn.is to accept JQuery and node objects, and a small fix for winnow getting an undefined selector

This commit is contained in:
Timmy Willison 2011-01-24 16:18:19 -05:00
parent 6c18a1becb
commit ed48787ec5
2 changed files with 58 additions and 7 deletions

View file

@ -60,7 +60,8 @@ jQuery.fn.extend({
},
is: function( selector ) {
return !!selector && jQuery.filter( selector, this ).length > 0;
return !!selector && (typeof selector === "string" ? jQuery.filter( selector, this ).length > 0 :
this.filter( selector ).length > 0);
},
closest: function( selectors, context ) {
@ -286,7 +287,7 @@ function winnow( elements, qualifier, keep ) {
return retVal === keep;
});
} else if ( qualifier.nodeType ) {
} else if ( qualifier && qualifier.nodeType ) {
return jQuery.grep(elements, function( elem, i ) {
return (elem === qualifier) === keep;
});