diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2013-04-20 10:02:07 -0400 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2013-04-20 10:06:31 -0400 |
commit | d754b50cb5197a30bbdb87396b2fcfe2301b42fe (patch) | |
tree | 9ff597ef4bc807a9dd21eb20d380f0dafe2dc448 /src | |
parent | ebecdac24220cae4671c5a7d8dc16097077dac30 (diff) | |
download | jquery-d754b50cb5197a30bbdb87396b2fcfe2301b42fe.tar.gz jquery-d754b50cb5197a30bbdb87396b2fcfe2301b42fe.zip |
No ticket: Reduce .find
(cherry picked from commit 85b3c82445d9e88c6e747a33ad97f5f9e35a7d35)
Diffstat (limited to 'src')
-rw-r--r-- | src/traversing.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/traversing.js b/src/traversing.js index a063a4612..e6b5913e2 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -10,13 +10,14 @@ var isSimple = /^.[^:#\[\.,]*$/, jQuery.fn.extend({ find: function( selector ) { - var self, matched, i, - l = this.length; + var i, + ret = [], + self = this, + len = self.length; if ( typeof selector !== "string" ) { - self = this; return this.pushStack( jQuery( selector ).filter(function() { - for ( i = 0; i < l; i++ ) { + for ( i = 0; i < len; i++ ) { if ( jQuery.contains( self[ i ], this ) ) { return true; } @@ -24,15 +25,14 @@ jQuery.fn.extend({ }) ); } - matched = []; - for ( i = 0; i < l; i++ ) { - jQuery.find( selector, this[ i ], matched ); + for ( i = 0; i < len; i++ ) { + jQuery.find( selector, self[ i ], ret ); } // Needed because $( selector, context ) becomes $( context ).find( selector ) - matched = this.pushStack( l > 1 ? jQuery.unique( matched ) : matched ); - matched.selector = ( this.selector ? this.selector + " " : "" ) + selector; - return matched; + ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); + ret.selector = this.selector ? this.selector + " " + selector : selector; + return ret; }, has: function( target ) { |