mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
2.0: Removes attachEvent paths for jQuery.ready()
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
This commit is contained in:
parent
861a45b8ff
commit
eb5df5e162
43
src/core.js
43
src/core.js
@ -72,15 +72,8 @@ var
|
|||||||
|
|
||||||
// The ready event handler and self cleanup method
|
// The ready event handler and self cleanup method
|
||||||
DOMContentLoaded = function() {
|
DOMContentLoaded = function() {
|
||||||
if ( document.addEventListener ) {
|
|
||||||
document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
|
document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
|
||||||
jQuery.ready();
|
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();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
jQuery.fn = jQuery.prototype = {
|
jQuery.fn = jQuery.prototype = {
|
||||||
@ -864,46 +857,12 @@ jQuery.ready.promise = function( obj ) {
|
|||||||
setTimeout( jQuery.ready );
|
setTimeout( jQuery.ready );
|
||||||
|
|
||||||
// Standards-based browsers support DOMContentLoaded
|
// Standards-based browsers support DOMContentLoaded
|
||||||
} else if ( document.addEventListener ) {
|
} else {
|
||||||
// Use the handy event callback
|
// Use the handy event callback
|
||||||
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
|
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
|
||||||
|
|
||||||
// A fallback to window.onload, that will always work
|
// A fallback to window.onload, that will always work
|
||||||
window.addEventListener( "load", jQuery.ready, false );
|
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 );
|
return readyList.promise( obj );
|
||||||
|
Loading…
Reference in New Issue
Block a user