From 4f786ba4d2a5544cb48f589d2659d6cab84efc34 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Sat, 20 Apr 2013 11:40:27 -0400 Subject: Fix #13797: .is with single-node context --- src/traversing.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/traversing.js') diff --git a/src/traversing.js b/src/traversing.js index 4a274806e..a9c9c9796 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -58,14 +58,16 @@ jQuery.fn.extend({ }, is: function( selector ) { - return !!selector && ( - typeof selector === "string" ? - // If this is a positional/relative selector, check membership in the returned set - // so $("p:first").is("p:last") won't return true for a doc with two "p". - rneedsContext.test( selector ) ? - jQuery( selector, this.context ).index( this[0] ) >= 0 : - jQuery.filter( selector, this ).length > 0 : - this.filter( selector ).length > 0 ); + return !!winnow( + this, + + // If this is a positional/relative selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + typeof selector === "string" && rneedsContext.test( selector ) ? + jQuery( selector ) : + selector || [], + false + ).length; }, closest: function( selectors, context ) { -- cgit v1.2.3