Added an optimization for the case where $("body") is used.

This commit is contained in:
John Resig 2009-09-07 17:20:38 +00:00
parent 50d78e7658
commit b7d4e0e46c

View file

@ -48,6 +48,11 @@ jQuery.fn = jQuery.prototype = {
return this; return this;
} }
// $("body"): Shortcut for quickly finding the body element
if ( selector === "body" && !context && document.body ) {
selector = document.body;
}
// Handle $(DOMElement) // Handle $(DOMElement)
if ( selector.nodeType ) { if ( selector.nodeType ) {
this.context = this[0] = selector; this.context = this[0] = selector;