X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcore.js;h=2b00627dbee3af23d20afcf838baf78c8d29c07b;hb=ae9df1412c41b1ae676d3808c323b0f01e0b0600;hp=d6ef236f48a8622d659a53fb2fd034ef84946aa6;hpb=2663041924af36a26a30e60da5d97e2ab9fed5ec;p=jquery.git diff --git a/src/core.js b/src/core.js index d6ef236..2b00627 100644 --- a/src/core.js +++ b/src/core.js @@ -360,11 +360,20 @@ jQuery.extend({ // Is the DOM ready to be used? Set to true once it occurs. isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, // Handle when the DOM is ready - ready: function() { + ready: function( wait ) { + // A third-party is pushing the ready event forwards + if ( wait === true ) { + jQuery.readyWait--; + } + // Make sure that the DOM is not already loaded - if ( !jQuery.isReady ) { + if ( !jQuery.readyWait && !jQuery.isReady ) { // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). if ( !document.body ) { return setTimeout( jQuery.ready, 13 ); @@ -373,6 +382,11 @@ jQuery.extend({ // Remember that the DOM is ready jQuery.isReady = true; + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + // If there are functions bound, to execute if ( readyList ) { // Execute all of them @@ -826,6 +840,6 @@ function doScrollCheck() { } // Expose jQuery to the global object -return window.jQuery = window.$ = jQuery; +return (window.jQuery = window.$ = jQuery); })();