From: Mike Sherov Date: Fri, 4 May 2012 17:31:35 +0000 (-0400) Subject: reduce complexity of ready further, and try manipulating DOM to make sure we're reall... X-Git-Tag: 1.8b1~166 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=714b8ffd2b28af446fea8f25e369597d7c509cb4;p=jquery.git reduce complexity of ready further, and try manipulating DOM to make sure we're really ready --- diff --git a/src/core.js b/src/core.js index b5b8efcd7..6746802e6 100644 --- a/src/core.js +++ b/src/core.js @@ -59,18 +59,16 @@ var jQuery = function( selector, context ) { // The deferred used on DOM ready readyList, - // The ready event handler - // Cleanup function for the document ready method + // The ready event handler and self cleanup method DOMContentLoaded = function() { if ( document.addEventListener ) { document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); - jQuery.ready(); - } else if ( document.readyState !== "loading" ) { - // if document.addEventListener isn't present, we assume detachEvent is! - // Make sure body exists by checking readystate, at least, in case IE gets a little overzealous (ticket #5443). + } else { + // we're here because readyState !== "loading" in oldIE + // which is good enough for us to call the dom ready! document.detachEvent( "onreadystatechange", DOMContentLoaded ); - jQuery.ready(); } + jQuery.ready(); }, // Save a reference to some core methods diff --git a/test/data/event/asyncReady.html b/test/data/event/asyncReady.html index e32ff9cfb..0b389d854 100644 --- a/test/data/event/asyncReady.html +++ b/test/data/event/asyncReady.html @@ -14,6 +14,7 @@ if ( document.attachEvent ) { el.type = "text/javascript"; el.onload = function() { jQuery( document ).ready(function() { + jQuery("body").append("
modifying DOM
"); window.parent.iframeCallback( true ); }); } diff --git a/test/data/event/syncReady.html b/test/data/event/syncReady.html index df66bc623..1b85ce0a8 100644 --- a/test/data/event/syncReady.html +++ b/test/data/event/syncReady.html @@ -8,6 +8,7 @@