Optimize jQuery() for the case $("TAG").
authorJohn Resig <jeresig@gmail.com>
Tue, 8 Sep 2009 04:26:47 +0000 (04:26 +0000)
committerJohn Resig <jeresig@gmail.com>
Tue, 8 Sep 2009 04:26:47 +0000 (04:26 +0000)
src/core.js

index a7cbdc9..5fa944b 100644 (file)
@@ -109,6 +109,10 @@ jQuery.fn = jQuery.prototype = {
                                        return this;
                                }
 
+                       // HANDLE: $("TAG")
+                       } else if ( !context && /^\w+$/.test( selector ) ) {
+                               selector = document.getElementsByTagName( selector );
+
                        // HANDLE: $(expr, $(...))
                        } else if ( !context || context.jquery ) {
                                return (context || rootjQuery).find( selector );