From a9c2a9bf61af4c09e8f089b45e8986b9a5416d46 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Thu, 23 Aug 2012 17:46:12 -0400 Subject: [PATCH] Scorch the earth and retreat on readyState interactive! Close gh-907. --- src/core.js | 4 +-- test/data/event/asyncReady.html | 30 ------------------ test/data/event/longLoad.php | 6 ---- test/data/event/partialLoadReady.php | 40 ----------------------- test/data/event/syncReadyLongLoad.html | 26 --------------- test/unit/event.js | 44 +++++++------------------- 6 files changed, 13 insertions(+), 137 deletions(-) delete mode 100644 test/data/event/asyncReady.html delete mode 100644 test/data/event/longLoad.php delete mode 100644 test/data/event/partialLoadReady.php delete mode 100644 test/data/event/syncReadyLongLoad.html diff --git a/src/core.js b/src/core.js index 4652c5ad7..916e7ad8d 100644 --- a/src/core.js +++ b/src/core.js @@ -831,9 +831,9 @@ jQuery.ready.promise = function( obj ) { readyList = jQuery.Deferred(); // 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 + // 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.attachEvent ? document.readyState === "complete" : document.readyState !== "loading" ) { + if ( document.readyState === "complete" ) { // 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 deleted file mode 100644 index 48a967a2a..000000000 --- a/test/data/event/asyncReady.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - -Test case for jQuery ticket #10067 - - - - - - -
- - - - - diff --git a/test/data/event/longLoad.php b/test/data/event/longLoad.php deleted file mode 100644 index ba1d43f82..000000000 --- a/test/data/event/longLoad.php +++ /dev/null @@ -1,6 +0,0 @@ - - \ No newline at end of file diff --git a/test/data/event/partialLoadReady.php b/test/data/event/partialLoadReady.php deleted file mode 100644 index 1a93b0b8a..000000000 --- a/test/data/event/partialLoadReady.php +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - -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/event/syncReadyLongLoad.html b/test/data/event/syncReadyLongLoad.html deleted file mode 100644 index 83f2859ed..000000000 --- a/test/data/event/syncReadyLongLoad.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - -Test case for jQuery ticket #10067 - - - - - - - - -
- - - - - diff --git a/test/unit/event.js b/test/unit/event.js index f58eb59e6..74cf1b9b7 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2882,39 +2882,17 @@ test("fixHooks extensions", function() { jQuery.event.fixHooks.click = saved; }); +testIframeWithCallback( "jQuery.ready promise", "event/promiseReady.html", function( isOk ) { + expect(1); + ok( isOk, "$.when( $.ready ) works" ); +}); -// async loaded tests expect jQuery to be loaded as a single file -// if we're not doing PHP concat, then we fall back to document.write -// which breaks order of execution on async loaded files -// also need PHP to make the incepted IFRAME hang +// need PHP here to make the incepted IFRAME hang if ( hasPHP ) { - testIframeWithCallback( "jQuery.ready promise", "event/promiseReady.html", function( isOk ) { - expect(1); - ok( isOk, "$.when( $.ready ) works" ); - }); - testIframeWithCallback( "jQuery.ready synchronous load with long loading subresources", "event/syncReady.html", function( isOk ) { expect(1); ok( isOk, "jQuery loaded synchronously fires ready when the DOM can truly be interacted with" ); }); - - testIframeWithCallback( "jQuery.ready synchronous load with partially loaded page", "event/partialLoadReady.php", function( isOk ) { - expect(1); - ok( isOk, "jQuery loaded synchronously fires ready when the DOM can truly be interacted with" ); - }); - - // allIE needs all subresources and full page to be loaded before it can gaurantee the document is truly ready to be interacted with - if( !document.attachEvent ) { - testIframeWithCallback( "jQuery.ready synchronous load with long loading iframe", "event/syncReadyLongLoad.html", function( isOk ) { - expect(1); - ok( isOk, "jQuery loaded synchronously fires ready before all sub-resources are loaded" ); - }); - - testIframeWithCallback( "jQuery.ready asynchronous load with long loading iframe", "event/asyncReady.html", function( isOk ) { - expect(1); - ok( isOk, "jQuery loaded asynchronously fires ready before all sub-resources are loaded" ); - }); - } } (function(){ @@ -2994,22 +2972,22 @@ test("change handler should be detached from element", function() { expect( 2 ); var $fixture = jQuery( "" ).appendTo( "body" ); - + var originRemoveEvent = jQuery.removeEvent; - + var wrapperRemoveEvent = function(elem, type, handle){ equal("change", type, "Event handler for 'change' event should be removed"); equal("change-ie-leak", jQuery(elem).attr("id"), "Event handler for 'change' event should be removed from appropriate element"); originRemoveEvent(elem, type, handle); }; - + jQuery.removeEvent = wrapperRemoveEvent ; - + $fixture.bind( "change", function( event ) {}); $fixture.unbind( "change" ); - + $fixture.remove(); - + jQuery.removeEvent = originRemoveEvent; }); -- 2.39.5