aboutsummaryrefslogtreecommitdiffstats
path: root/src/traversing.js
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2013-04-20 11:40:27 -0400
committerRichard Gibson <richard.gibson@gmail.com>2013-04-20 11:51:51 -0400
commitfb1731ab163424e22bac4372f15cda1195bfaa85 (patch)
treec1b54612ea383860694c1976ca93d79f376cf06c /src/traversing.js
parentd754b50cb5197a30bbdb87396b2fcfe2301b42fe (diff)
downloadjquery-fb1731ab163424e22bac4372f15cda1195bfaa85.tar.gz
jquery-fb1731ab163424e22bac4372f15cda1195bfaa85.zip
Fix #13797: .is with single-node context
(cherry picked from commit 4f786ba4d2a5544cb48f589d2659d6cab84efc34)
Diffstat (limited to 'src/traversing.js')
-rw-r--r--src/traversing.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/traversing.js b/src/traversing.js
index e6b5913e2..5e9fe1943 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 ) {