Fixes #11264 or rather seriously limits the risk of global ajaxSettings screwing with script loading in domManip. Gotta love globals and sneaky dependencies. Unit test added.

This commit is contained in:
jaubourg 2012-03-07 16:54:05 +01:00
parent 484cea1b56
commit d3fad51cad
3 changed files with 23 additions and 0 deletions

View File

@ -351,6 +351,8 @@ jQuery.fn.extend({
jQuery.each( scripts, function( i, elem ) { jQuery.each( scripts, function( i, elem ) {
if ( elem.src ) { if ( elem.src ) {
jQuery.ajax({ jQuery.ajax({
type: "GET",
global: false,
url: elem.src, url: elem.src,
async: false, async: false,
dataType: "script" dataType: "script"

1
test/data/evalScript.php Normal file
View File

@ -0,0 +1 @@
ok( "<?php echo $_SERVER['REQUEST_METHOD'] ?>" === "GET", "request method is <?php echo $_SERVER['REQUEST_METHOD'] ?>" );

View File

@ -2336,6 +2336,26 @@ test( "jQuery.ajax - loading binary data shouldn't throw an exception in IE (#11
}); });
}); });
test( "jQuery.domManip - no side effect because of ajaxSetup or global events (#11264)", function() {
expect( 1 );
jQuery.ajaxSetup({
type: "POST"
});
jQuery( document ).bind( "ajaxStart ajaxStop", function() {
ok( false, "Global event triggered" );
});
jQuery( "#qunit-fixture" ).append( "<script src='data/evalScript.php'></script>" );
jQuery( document ).unbind( "ajaxStart ajaxStop" );
jQuery.ajaxSetup({
type: "GET"
});
});
test("jQuery.ajax - active counter", function() { test("jQuery.ajax - active counter", function() {
ok( jQuery.active == 0, "ajax active counter should be zero: " + jQuery.active ); ok( jQuery.active == 0, "ajax active counter should be zero: " + jQuery.active );
}); });