Converted jQuery to use the new DOM Ready technique (by checking scroll). A single setTimeout loop is used for both IE and Safari now. Fixex bugs #1320 and #1561.
This commit is contained in:
parent
a9add215ea
commit
6e8a8c5359
49
src/event.js
49
src/event.js
|
@ -402,10 +402,6 @@ jQuery.extend({
|
||||||
// Remove event listener to avoid memory leak
|
// Remove event listener to avoid memory leak
|
||||||
if ( jQuery.browser.mozilla || jQuery.browser.opera )
|
if ( jQuery.browser.mozilla || jQuery.browser.opera )
|
||||||
document.removeEventListener( "DOMContentLoaded", jQuery.ready, false );
|
document.removeEventListener( "DOMContentLoaded", jQuery.ready, false );
|
||||||
|
|
||||||
// Remove script element used by IE hack
|
|
||||||
if( !window.frames.length ) // don't remove if frames are present (#1187)
|
|
||||||
jQuery(window).load(function(){ jQuery("#__ie_init").remove(); });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -432,43 +428,22 @@ function bindReady(){
|
||||||
// Use the handy event callback
|
// Use the handy event callback
|
||||||
document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
|
document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
|
||||||
|
|
||||||
// If IE is used, use the excellent hack by Matthias Miller
|
// If Safari or IE is used
|
||||||
// http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
|
else
|
||||||
else if ( jQuery.browser.msie ) {
|
// Continually check to see if the document is ready
|
||||||
|
(function timer() {
|
||||||
// Only works if you document.write() it
|
try {
|
||||||
document.write("<scr" + "ipt id=__ie_init defer=true " +
|
// If IE is used, use the excellent hack by Hedger Wang and Andrea Giammarchi
|
||||||
"src=//:><\/script>");
|
// http://www.3site.eu/jstests/onContent/DOMReadyAnddoScroll.php
|
||||||
|
if ( jQuery.browser.msie || document.readyState != "loaded" && document.readyState != "complete" )
|
||||||
// Use the defer script hack
|
document.firstChild.doScroll("left");
|
||||||
var script = document.getElementById("__ie_init");
|
|
||||||
|
|
||||||
// script does not exist if jQuery is loaded dynamically
|
|
||||||
if ( script )
|
|
||||||
script.onreadystatechange = function() {
|
|
||||||
if ( this.readyState != "complete" ) return;
|
|
||||||
jQuery.ready();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Clear from memory
|
|
||||||
script = null;
|
|
||||||
|
|
||||||
// If Safari is used
|
|
||||||
} else if ( jQuery.browser.safari )
|
|
||||||
// Continually check to see if the document.readyState is valid
|
|
||||||
jQuery.safariTimer = setInterval(function(){
|
|
||||||
// loaded and complete are both valid states
|
|
||||||
if ( document.readyState == "loaded" ||
|
|
||||||
document.readyState == "complete" ) {
|
|
||||||
|
|
||||||
// If either one are found, remove the timer
|
|
||||||
clearInterval( jQuery.safariTimer );
|
|
||||||
jQuery.safariTimer = null;
|
|
||||||
|
|
||||||
// and execute any waiting functions
|
// and execute any waiting functions
|
||||||
jQuery.ready();
|
jQuery.ready();
|
||||||
|
} catch( error ) {
|
||||||
|
setTimeout( timer, 0 );
|
||||||
}
|
}
|
||||||
}, 10);
|
})();
|
||||||
|
|
||||||
// A fallback to window.onload, that will always work
|
// A fallback to window.onload, that will always work
|
||||||
jQuery.event.add( window, "load", jQuery.ready );
|
jQuery.event.add( window, "load", jQuery.ready );
|
||||||
|
|
Loading…
Reference in a new issue