From 0f553ed0ca0c50c5f66377e9f2c6314f822e8f25 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 19 Aug 2012 17:41:43 -0400 Subject: [PATCH] Fix #12282. IE has premature .readyState == "interactive". Close gh-901. --- src/core.js | 7 ++--- test/data/event/partialLoadReady.php | 40 ++++++++++++++++++++++++++++ test/data/testinit.js | 2 +- test/unit/event.js | 25 ++++++++++------- test/unit/support.js | 4 +-- 5 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 test/data/event/partialLoadReady.php diff --git a/src/core.js b/src/core.js index f9ee24852..4334ae261 100644 --- a/src/core.js +++ b/src/core.js @@ -830,9 +830,10 @@ jQuery.ready.promise = function( obj ) { readyList = jQuery.Deferred(); - // Catch cases where $(document).ready() is called after the - // browser event has already occurred. - if ( document.readyState === "complete" || ( document.readyState !== "loading" && document.addEventListener ) ) { + // Catch cases where $(document).ready() is called after the browser event has already occurred. + // IE10 and lower don't handle "interactive" properly... use a weak inference to detect it + // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 + if ( document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading" ) { // Handle it asynchronously to allow scripts the opportunity to delay ready setTimeout( jQuery.ready, 1 ); diff --git a/test/data/event/partialLoadReady.php b/test/data/event/partialLoadReady.php new file mode 100644 index 000000000..000ee567b --- /dev/null +++ b/test/data/event/partialLoadReady.php @@ -0,0 +1,40 @@ + + + + + + +Test case for jQuery ticket #12282 + + + +

TEST

+ + + + + +

Sleeping for 1 seconds (simulating server side process)

+ + + +
ready + + \ No newline at end of file diff --git a/test/data/testinit.js b/test/data/testinit.js index 18f9e2845..fbc858665 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -223,7 +223,7 @@ function url( value ) { }, 0 ); }; iframe = jQuery( "
" ).append( - jQuery( "