From: John Resig Date: Sat, 11 Jul 2009 13:44:44 +0000 (+0000) Subject: Optimized jQuery(Element) to not call jQuery() twice. X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;ds=inline;h=fd2a2fed84b6c32e24a050356a8f422310bae927;p=jquery.git Optimized jQuery(Element) to not call jQuery() twice. --- diff --git a/src/core.js b/src/core.js index 78f48d7..cab3b54 100644 --- a/src/core.js +++ b/src/core.js @@ -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, $(...))