Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

2.0: Removes attachEvent paths for jQuery.ready() #1077

Closed
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+3 −49
Split
View
@@ -72,15 +72,8 @@ var
// The ready event handler and self cleanup method
DOMContentLoaded = function() {
- if ( document.addEventListener ) {
- document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
- jQuery.ready();
- } else if ( document.readyState === "complete" ) {
- // we're here because readyState === "complete" in oldIE
- // which is good enough for us to call the dom ready!
- document.detachEvent( "onreadystatechange", DOMContentLoaded );
- jQuery.ready();
- }
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+ jQuery.ready();
};
jQuery.fn = jQuery.prototype = {
@@ -385,11 +378,6 @@ jQuery.extend({
return;
}
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
- if ( !document.body ) {
- return setTimeout( jQuery.ready );
- }
-
// Remember that the DOM is ready
jQuery.isReady = true;
@@ -862,46 +850,12 @@ jQuery.ready.promise = function( obj ) {
setTimeout( jQuery.ready );
// Standards-based browsers support DOMContentLoaded
- } else if ( document.addEventListener ) {
+ } else {
// Use the handy event callback
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
// A fallback to window.onload, that will always work
window.addEventListener( "load", jQuery.ready, false );
-
- // If IE event model is used
- } else {
- // Ensure firing before onload, maybe late but safe also for iframes
- document.attachEvent( "onreadystatechange", DOMContentLoaded );
-
- // A fallback to window.onload, that will always work
- window.attachEvent( "onload", jQuery.ready );
-
- // If IE and not a frame
- // continually check to see if the document is ready
- var top = false;
-
- try {
- top = window.frameElement == null && document.documentElement;
- } catch(e) {}
-
- if ( top && top.doScroll ) {
- (function doScrollCheck() {
- if ( !jQuery.isReady ) {
-
- try {
- // Use the trick by Diego Perini
- // http://javascript.nwbox.com/IEContentLoaded/
- top.doScroll("left");
- } catch(e) {
- return setTimeout( doScrollCheck, 50 );
- }
-
- // and execute any waiting functions
- jQuery.ready();
- }
- })();
- }
}
}
return readyList.promise( obj );