]> source.dussan.org Git - jquery.git/commitdiff
Made the .unqiue() within .find() optional (speeds up calls).
authorJohn Resig <jeresig@gmail.com>
Tue, 6 Jan 2009 16:17:50 +0000 (16:17 +0000)
committerJohn Resig <jeresig@gmail.com>
Tue, 6 Jan 2009 16:17:50 +0000 (16:17 +0000)
src/core.js

index ad94ce10ccbeb27a4abaae68cb00f163451caae7..e2f1f0b330ec6f796158ece5dc50dba0fa54c5af 100644 (file)
@@ -261,13 +261,17 @@ jQuery.fn = jQuery.prototype = {
        },
 
        find: function( selector ) {
-               var elems = jQuery.map(this, function(elem){
-                       return jQuery.find( selector, elem );
-               });
+               if ( this.length === 1 ) {
+                       return this.pushStack( jQuery.find( selector, this[0] ), "find", selector );
+               } else {
+                       var elems = jQuery.map(this, function(elem){
+                               return jQuery.find( selector, elem );
+                       });
 
-               return this.pushStack( /[^+>] [^+>]/.test( selector ) ?
-                       jQuery.unique( elems ) :
-                       elems, "find", selector );
+                       return this.pushStack( /[^+>] [^+>]/.test( selector ) ?
+                               jQuery.unique( elems ) :
+                               elems, "find", selector );
+               }
        },
 
        clone: function( events ) {