]> source.dussan.org Git - jquery.git/commitdiff
Added a quick shortcut to improve the speed of $(DOMElement) by over 2x.
authorJohn Resig <jeresig@gmail.com>
Tue, 27 Nov 2007 01:03:49 +0000 (01:03 +0000)
committerJohn Resig <jeresig@gmail.com>
Tue, 27 Nov 2007 01:03:49 +0000 (01:03 +0000)
src/core.js

index a42e8f6577da105c9650f42b2c283b35c3d04d0c..b9d5247146298cb4577e08af02525cbb828d63d9 100644 (file)
@@ -36,8 +36,14 @@ jQuery.fn = jQuery.prototype = {
                // Make sure that a selection was provided
                selector = selector || document;
 
+               // Handle $(DOMElement)
+               if ( selector.nodeType ) {
+                       this[0] = selector;
+                       this.length = 1;
+                       return this;
+
                // Handle HTML strings
-               if ( typeof selector  == "string" ) {
+               } else if ( typeof selector  == "string" ) {
                        // Are we dealing with HTML string or an ID?
                        var match = quickExpr.exec( selector );