From 714b8ffd2b28af446fea8f25e369597d7c509cb4 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Fri, 4 May 2012 13:31:35 -0400 Subject: [PATCH] reduce complexity of ready further, and try manipulating DOM to make sure we're really ready --- src/core.js | 12 +++++------- test/data/event/asyncReady.html | 1 + test/data/event/syncReady.html | 1 + 3 files changed, 7 insertions(+), 7 deletions(-) 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 @@