mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Close GH-829: no ticket: smaller jQuery.ready.
This commit is contained in:
parent
6cdca88eee
commit
66501469c0
51
src/core.js
51
src/core.js
@ -367,8 +367,11 @@ jQuery.extend({
|
||||
// Handle when the DOM is ready
|
||||
ready: function( wait ) {
|
||||
|
||||
// Either a released hold or an DOMready/load event and not yet ready
|
||||
if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
|
||||
// Abort if there are pending holds or we're already ready
|
||||
if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
|
||||
if ( !document.body ) {
|
||||
return setTimeout( jQuery.ready, 1 );
|
||||
@ -387,8 +390,7 @@ jQuery.extend({
|
||||
|
||||
// Trigger any bound ready events
|
||||
if ( jQuery.fn.trigger ) {
|
||||
jQuery( document ).trigger( "ready" ).off( "ready" );
|
||||
}
|
||||
jQuery( document ).trigger("ready").off("ready");
|
||||
}
|
||||
},
|
||||
|
||||
@ -853,14 +855,28 @@ jQuery.ready.promise = function( object ) {
|
||||
|
||||
// If IE and not a frame
|
||||
// continually check to see if the document is ready
|
||||
var toplevel = false;
|
||||
var top = false;
|
||||
|
||||
try {
|
||||
toplevel = window.frameElement == null;
|
||||
top = window.frameElement == null && document.documentElement;
|
||||
} catch(e) {}
|
||||
|
||||
if ( document.documentElement.doScroll && toplevel ) {
|
||||
doScrollCheck();
|
||||
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, 1 );
|
||||
}
|
||||
|
||||
// and execute any waiting functions
|
||||
jQuery.ready();
|
||||
}
|
||||
})();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -891,22 +907,3 @@ if ( core_rnotwhite.test( "\xA0" ) ) {
|
||||
|
||||
// All jQuery objects should point back to these
|
||||
rootjQuery = jQuery(document);
|
||||
|
||||
// The DOM ready check for Internet Explorer
|
||||
function doScrollCheck() {
|
||||
if ( jQuery.isReady ) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// If IE is used, use the trick by Diego Perini
|
||||
// http://javascript.nwbox.com/IEContentLoaded/
|
||||
document.documentElement.doScroll("left");
|
||||
} catch(e) {
|
||||
setTimeout( doScrollCheck, 1 );
|
||||
return;
|
||||
}
|
||||
|
||||
// and execute any waiting functions
|
||||
jQuery.ready();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user