diff options
author | Mike Sherov <mike.sherov@gmail.com> | 2012-05-04 13:31:35 -0400 |
---|---|---|
committer | Mike Sherov <mike.sherov@gmail.com> | 2012-05-04 13:31:35 -0400 |
commit | 714b8ffd2b28af446fea8f25e369597d7c509cb4 (patch) | |
tree | a5236d88b0e8406439ad7a1ea5d49da60b492018 | |
parent | f925c7a1c93afd7eae1edcf540e9d4374b2aa27b (diff) | |
download | jquery-714b8ffd2b28af446fea8f25e369597d7c509cb4.tar.gz jquery-714b8ffd2b28af446fea8f25e369597d7c509cb4.zip |
reduce complexity of ready further, and try manipulating DOM to make sure we're really ready
-rw-r--r-- | src/core.js | 12 | ||||
-rw-r--r-- | test/data/event/asyncReady.html | 1 | ||||
-rw-r--r-- | 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("<div>modifying DOM</div>"); 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 @@ <body> <script type="text/javascript"> jQuery( document ).ready(function () { + jQuery("body").append("<div>modifying DOM</div>"); window.parent.iframeCallback( true ); }); </script> |