Make sure that when multiple variables are being declared that assignments are each...
[jquery.git] / src / core.js
index 158f479..8940ada 100644 (file)
@@ -33,6 +33,9 @@ var jQuery = function( selector, context ) {
        // Check for non-word characters
        rnonword = /\W/,
 
+       // Check for digits
+       rdigit = /\d/,
+
        // Match a standalone tag
        rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
 
@@ -91,7 +94,7 @@ jQuery.fn = jQuery.prototype = {
                }
                
                // The body element only exists once, optimize finding it
-               if ( selector === "body" && !context ) {
+               if ( selector === "body" && !context && document.body ) {
                        this.context = document;
                        this[0] = document.body;
                        this.selector = "body";
@@ -308,8 +311,11 @@ jQuery.fn = jQuery.prototype = {
 jQuery.fn.init.prototype = jQuery.fn;
 
 jQuery.extend = jQuery.fn.extend = function() {
-       // copy reference to target object
-       var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy, copyIsArray;
+        var options, name, src, copy, copyIsArray, clone,
+               target = arguments[0] || {},
+               i = 1,
+               length = arguments.length,
+               deep = false;
 
        // Handle a deep copy situation
        if ( typeof target === "boolean" ) {
@@ -397,7 +403,7 @@ jQuery.extend({
                if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) {
                        // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
                        if ( !document.body ) {
-                               return setTimeout( jQuery.ready, 13 );
+                               return setTimeout( jQuery.ready, 1 );
                        }
 
                        // Remember that the DOM is ready
@@ -421,8 +427,8 @@ jQuery.extend({
                        }
 
                        // Trigger any bound ready events
-                       if ( jQuery.fn.triggerHandler ) {
-                               jQuery( document ).triggerHandler( "ready" );
+                       if ( jQuery.fn.trigger ) {
+                               jQuery( document ).trigger( "ready" ).unbind( "ready" );
                        }
                }
        },
@@ -437,7 +443,8 @@ jQuery.extend({
                // Catch cases where $(document).ready() is called after the
                // browser event has already occurred.
                if ( document.readyState === "complete" ) {
-                       return jQuery.ready();
+                       // Handle it asynchronously to allow scripts the opportunity to delay ready
+                       return setTimeout( jQuery.ready, 1 );
                }
 
                // Mozilla, Opera and webkit nightlies currently support this event
@@ -487,6 +494,10 @@ jQuery.extend({
                return obj && typeof obj === "object" && "setInterval" in obj;
        },
 
+       isNaN: function( obj ) {
+               return obj == null || !rdigit.test( obj ) || isNaN( obj );
+       },
+
        type: function( obj ) {
                return obj == null ?
                        String( obj ) :
@@ -670,7 +681,8 @@ jQuery.extend({
        },
 
        merge: function( first, second ) {
-               var i = first.length, j = 0;
+               var i = first.length,
+                       j = 0;
 
                if ( typeof second.length === "number" ) {
                        for ( var l = second.length; j < l; j++ ) {