mirror of
https://github.com/jquery/jquery.git
synced 2024-12-09 08:04:24 +00:00
reduce complexity of ready further, and try manipulating DOM to make sure we're really ready
This commit is contained in:
parent
f925c7a1c9
commit
714b8ffd2b
12
src/core.js
12
src/core.js
@ -59,18 +59,16 @@ var jQuery = function( selector, context ) {
|
|||||||
// The deferred used on DOM ready
|
// The deferred used on DOM ready
|
||||||
readyList,
|
readyList,
|
||||||
|
|
||||||
// The ready event handler
|
// The ready event handler and self cleanup method
|
||||||
// Cleanup function for the document ready method
|
|
||||||
DOMContentLoaded = function() {
|
DOMContentLoaded = function() {
|
||||||
if ( document.addEventListener ) {
|
if ( document.addEventListener ) {
|
||||||
document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
|
document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
|
||||||
jQuery.ready();
|
} else {
|
||||||
} else if ( document.readyState !== "loading" ) {
|
// we're here because readyState !== "loading" in oldIE
|
||||||
// if document.addEventListener isn't present, we assume detachEvent is!
|
// which is good enough for us to call the dom ready!
|
||||||
// Make sure body exists by checking readystate, at least, in case IE gets a little overzealous (ticket #5443).
|
|
||||||
document.detachEvent( "onreadystatechange", DOMContentLoaded );
|
document.detachEvent( "onreadystatechange", DOMContentLoaded );
|
||||||
jQuery.ready();
|
|
||||||
}
|
}
|
||||||
|
jQuery.ready();
|
||||||
},
|
},
|
||||||
|
|
||||||
// Save a reference to some core methods
|
// Save a reference to some core methods
|
||||||
|
@ -14,6 +14,7 @@ if ( document.attachEvent ) {
|
|||||||
el.type = "text/javascript";
|
el.type = "text/javascript";
|
||||||
el.onload = function() {
|
el.onload = function() {
|
||||||
jQuery( document ).ready(function() {
|
jQuery( document ).ready(function() {
|
||||||
|
jQuery("body").append("<div>modifying DOM</div>");
|
||||||
window.parent.iframeCallback( true );
|
window.parent.iframeCallback( true );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery( document ).ready(function () {
|
jQuery( document ).ready(function () {
|
||||||
|
jQuery("body").append("<div>modifying DOM</div>");
|
||||||
window.parent.iframeCallback( true );
|
window.parent.iframeCallback( true );
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user