diff --git a/src/core/ready.js b/src/core/ready.js index 49c1da202..da7a0a292 100644 --- a/src/core/ready.js +++ b/src/core/ready.js @@ -97,11 +97,10 @@ jQuery.ready.promise = function( obj ) { // Catch cases where $(document).ready() is called // after the browser event has already occurred. - // we once tried to use readyState "interactive" here, - // but it caused issues like the one - // discovered by ChrisS here: - // http://bugs.jquery.com/ticket/12282#comment:15 - if ( document.readyState === "complete" ) { + // Support: IE6-10 + // Older IE sometimes signals "interactive" too soon + if ( document.readyState === "complete" || + ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { // Handle it asynchronously to allow scripts the opportunity to delay ready window.setTimeout( jQuery.ready ); diff --git a/test/data/event/interactiveReady.html b/test/data/event/interactiveReady.html new file mode 100644 index 000000000..77b37104d --- /dev/null +++ b/test/data/event/interactiveReady.html @@ -0,0 +1,23 @@ + + + + +Test case for gh-2100 + + + + + + + + +
+ + diff --git a/test/unit/event.js b/test/unit/event.js index c8c0667d3..14fcba0b3 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2589,6 +2589,18 @@ testIframeWithCallback( } ); +// need PHP here to make the incepted IFRAME hang +if ( hasPHP ) { + testIframeWithCallback( + "jQuery.ready uses interactive", + "event/interactiveReady.html", + function( isOk, assert ) { + assert.expect( 1 ); + assert.ok( isOk, "jQuery fires ready when the DOM can truly be interacted with" ); + } + ); +} + testIframeWithCallback( "Focusing iframe element", "event/focusElem.html",