Delay the result of the readyState check to give scripts the opportunity to delay...
[jquery.git] / src / core.js
index 9cb519b..f6a07eb 100644 (file)
@@ -429,7 +429,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, 13 );
                }
 
                // Mozilla, Opera and webkit nightlies currently support this event
@@ -476,7 +477,7 @@ jQuery.extend({
 
        // A crude way of determining if an object is a window
        isWindow: function( obj ) {
-               return "setInterval" in obj;
+               return obj && typeof obj === "object" && "setInterval" in obj;
        },
 
        type: function( obj ) {