]> source.dussan.org Git - jquery.git/commitdiff
Optimized jQuery(Element) to not call jQuery() twice.
authorJohn Resig <jeresig@gmail.com>
Sat, 11 Jul 2009 13:44:44 +0000 (13:44 +0000)
committerJohn Resig <jeresig@gmail.com>
Sat, 11 Jul 2009 13:44:44 +0000 (13:44 +0000)
src/core.js

index 78f48d71b66e1f843fdbfdb1303c0019b8757040..cab3b54c3a55e7d9c90e8a4c21400eccdefa45e7 100644 (file)
@@ -72,10 +72,13 @@ jQuery.fn = jQuery.prototype = {
                                        }
 
                                        // Otherwise, we inject the element directly into the jQuery object
-                                       ret = jQuery( elem || null );
-                                       ret.context = document;
-                                       ret.selector = selector;
-                                       return ret;
+                                       this.length = elem ? 1 : 0;
+                                       if ( elem ) {
+                                               this[0] = elem;
+                                       }
+                                       this.context = document;
+                                       this.selector = selector;
+                                       return this;
                                }
 
                        // HANDLE: $(expr, $(...))