Skip to content

Commit

Permalink
Fix #13349. No need to sort simple .find() cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmethvin committed Jan 30, 2013
1 parent c4dd702 commit 1bbe2b1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/traversing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
},
Expand Down

0 comments on commit 1bbe2b1

Please sign in to comment.