aboutsummaryrefslogtreecommitdiffstats
path: root/src/traversing.js
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2013-01-29 20:57:26 -0500
committerDave Methvin <dave.methvin@gmail.com>2013-01-29 20:58:26 -0500
commit1bbe2b1ded24edf7bf7b18512aff4148591803da (patch)
treebfb1213d8099fd74f356869a4b9c3b939eae966e /src/traversing.js
parentc4dd702eda2a545a66b8a90ee0291eb46a114f93 (diff)
downloadjquery-1bbe2b1ded24edf7bf7b18512aff4148591803da.tar.gz
jquery-1bbe2b1ded24edf7bf7b18512aff4148591803da.zip
Fix #13349. No need to sort simple .find() cases.
Diffstat (limited to 'src/traversing.js')
-rw-r--r--src/traversing.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/traversing.js b/src/traversing.js
index 99c381010..8d8b9930f 100644
--- a/src/traversing.js
+++ b/src/traversing.js
@@ -12,12 +12,13 @@ var runtil = /Until$/,
jQuery.fn.extend({
find: function( selector ) {
- var i, ret, self;
+ var i, ret, self,
+ len = this.length;
if ( typeof selector !== "string" ) {
self = this;
return this.pushStack( jQuery( selector ).filter(function() {
- for ( i = 0; i < self.length; i++ ) {
+ for ( i = 0; i < len; i++ ) {
if ( jQuery.contains( self[ i ], this ) ) {
return true;
}
@@ -26,12 +27,12 @@ jQuery.fn.extend({
}
ret = [];
- for ( i = 0; i < this.length; i++ ) {
+ for ( i = 0; i < len; i++ ) {
jQuery.find( selector, this[ i ], ret );
}
// Needed because $( selector, context ) becomes $( context ).find( selector )
- ret = this.pushStack( jQuery.unique( ret ) );
+ ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
ret.selector = ( this.selector ? this.selector + " " : "" ) + selector;
return ret;
},