Fix #10067. Create jQuery.quickReady; closes gh-736.

Allows us to get to the ready state sooner by not waiting for iframes to load. If that causes backcompat pain, use `jQuery.quickReady = false` as prescribed by your developer.
This commit is contained in:
Mike Sherov
2012-04-23 15:43:26 -04:00
committed by Dave Methvin
parent 58ed62ed12
commit 54fab3174c
12 changed files with 149 additions and 48 deletions

View File

@@ -2794,6 +2794,26 @@ test("fixHooks extensions", function() {
jQuery.event.fixHooks.click = saved;
});
testIframeWithCallback( "jQuery.ready sync load", "event/syncReady", function( isOk ) {
expect(1);
ok( isOk, "jQuery loaded synchronously fires ready before all sub-resources are loaded" );
});
// async loaded tests expect jQuery to be loaded as a single file
// if we're not doing PHP concat, then we fall back to document.write
// which breaks order of execution on async loaded files
if ( hasPHP ) {
testIframeWithCallback( "jQuery.ready async load with quickReady true", "event/asyncQuickReadyTrue", function( isOk ) {
expect(1);
ok( isOk, "jQuery loaded asynchronously with quickReady true fires ready before all sub-resources are loaded" );
});
testIframeWithCallback( "jQuery.ready async load with quickReady false", "event/asyncQuickReadyFalse", function( isOk ) {
expect(1);
ok( isOk, "jQuery loaded asynchronously with quickReady false fires ready after all sub-resources are loaded" );
});
}
(function(){
// This code must be run before DOM ready!
var notYetReady, noEarlyExecution,

View File

@@ -1,37 +1,10 @@
module("support", { teardown: moduleTeardown });
function supportIFrameTest( title, url, noDisplay, func ) {
if ( noDisplay !== true ) {
func = noDisplay;
noDisplay = false;
}
test( title, function() {
var iframe;
stop();
window.supportCallback = function() {
var self = this,
args = arguments;
setTimeout( function() {
window.supportCallback = undefined;
iframe.remove();
func.apply( self, args );
start();
}, 0 );
};
iframe = jQuery( "<div/>" ).css( "display", noDisplay ? "none" : "block" ).append(
jQuery( "<iframe/>" ).attr( "src", "data/support/" + url + ".html" )
).appendTo( "body" );
});
}
supportIFrameTest( "proper boxModel in compatMode CSS1Compat (IE6 and IE7)", "boxModelIE", function( compatMode, boxModel ) {
testIframeWithCallback( "proper boxModel in compatMode CSS1Compat (IE6 and IE7)", "support/boxModelIE", function( compatMode, boxModel ) {
ok( compatMode !== "CSS1Compat" || boxModel, "boxModel properly detected" );
});
supportIFrameTest( "body background is not lost if set prior to loading jQuery (#9238)", "bodyBackground", function( color, support ) {
testIframeWithCallback( "body background is not lost if set prior to loading jQuery (#9238)", "support/bodyBackground", function( color, support ) {
expect( 2 );
var i,
passed = true,
@@ -56,7 +29,7 @@ supportIFrameTest( "body background is not lost if set prior to loading jQuery (
ok( passed, "Same support properties" );
});
supportIFrameTest( "A background on the testElement does not cause IE8 to crash (#9823)", "testElementCrash", function() {
testIframeWithCallback( "A background on the testElement does not cause IE8 to crash (#9823)", "support/testElementCrash", function() {
expect(1);
ok( true, "IE8 does not crash" );
});