Skip to content

Commit

Permalink
reduce complexity of ready further, and try manipulating DOM to make …
Browse files Browse the repository at this point in the history
…sure we're really ready
  • Loading branch information
mikesherov committed May 4, 2012
1 parent f925c7a commit 714b8ff
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/core.js
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/data/event/asyncReady.html
Expand Up @@ -14,6 +14,7 @@
el.type = "text/javascript";
el.onload = function() {
jQuery( document ).ready(function() {
jQuery("body").append("<div>modifying DOM</div>");
window.parent.iframeCallback( true );
});
}
Expand Down
1 change: 1 addition & 0 deletions test/data/event/syncReady.html
Expand Up @@ -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>
Expand Down

0 comments on commit 714b8ff

Please sign in to comment.