this.length = 1;
return this;
}
+
+ // The body element only exists once, optimize finding it
+ if ( selector === "body" && !context ) {
+ this.context = this[0] = document.body;
+ this.selector = "body";
+ this.length = 1;
+ return this;
+ }
// Handle HTML strings
if ( typeof selector === "string" ) {
ret = buildFragment( [ match[1] ], [ doc ] );
selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
}
-
+
return jQuery.merge( this, selector );
// HANDLE: $("#id")
this.selector = selector;
this.context = document;
selector = document.getElementsByTagName( selector );
+ return jQuery.merge( this, selector );
// HANDLE: $(expr, $(...))
} else if ( !context || context.jquery ) {
this.context = selector.context;
}
- return jQuery.isArray( selector ) ?
- this.setArray( selector ) :
- jQuery.makeArray( selector, this );
+ return jQuery.makeArray( selector, this );
},
// Start with an empty selector
for ( var l = second.length; j < l; j++ ) {
first[ i++ ] = second[ j ];
}
+
} else {
while ( second[j] !== undefined ) {
first[ i++ ] = second[ j++ ];
equals( jQuery(obj).selector, "div", "jQuery(jQueryObj) == jQueryObj" );
// can actually yield more than one, when iframes are included, the window is an array as well
- equals( 1, jQuery(window).length, "Correct number of elements generated for jQuery(window)" );
+ equals( jQuery(window).length, 1, "Correct number of elements generated for jQuery(window)" );
var main = jQuery("#main");