diff --git a/src/core.js b/src/core.js index c92774075..6b0615009 100644 --- a/src/core.js +++ b/src/core.js @@ -63,12 +63,13 @@ var DOMContentLoaded = function() { if ( document.addEventListener ) { document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); - } else { - // we're here because readyState !== "loading" in oldIE + jQuery.ready(); + } else if ( document.readyState === "complete" ) { + // we're here because readyState === "complete" in oldIE // which is good enough for us to call the dom ready! document.detachEvent( "onreadystatechange", DOMContentLoaded ); + jQuery.ready(); } - jQuery.ready(); }, // [[Class]] -> type pairs @@ -818,7 +819,7 @@ jQuery.ready.promise = function( obj ) { // Catch cases where $(document).ready() is called after the // browser event has already occurred. - if ( document.readyState !== "loading" ) { + if ( document.readyState === "complete" || ( document.readyState !== "loading" && document.addEventListener ) ) { // Handle it asynchronously to allow scripts the opportunity to delay ready setTimeout( jQuery.ready, 1 ); diff --git a/test/data/event/asyncReady.html b/test/data/event/asyncReady.html index 174c0f780..48a967a2a 100644 --- a/test/data/event/asyncReady.html +++ b/test/data/event/asyncReady.html @@ -4,27 +4,26 @@