From 1a2fdafd386a8f7be8b633634a684969921f8b8f Mon Sep 17 00:00:00 2001 From: John Resig Date: Tue, 27 Nov 2007 01:03:49 +0000 Subject: [PATCH] Added a quick shortcut to improve the speed of $(DOMElement) by over 2x. --- src/core.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core.js b/src/core.js index a42e8f6..b9d5247 100644 --- a/src/core.js +++ b/src/core.js @@ -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 ); -- 1.7.10.4