Skip to content

Commit d3fad51

Browse files
committed
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.
1 parent 484cea1 commit d3fad51

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/manipulation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ jQuery.fn.extend({
351351
jQuery.each( scripts, function( i, elem ) {
352352
if ( elem.src ) {
353353
jQuery.ajax({
354+
type: "GET",
355+
global: false,
354356
url: elem.src,
355357
async: false,
356358
dataType: "script"

test/data/evalScript.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ok( "<?php echo $_SERVER['REQUEST_METHOD'] ?>" === "GET", "request method is <?php echo $_SERVER['REQUEST_METHOD'] ?>" );

test/unit/ajax.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,6 +2336,26 @@ test( "jQuery.ajax - loading binary data shouldn't throw an exception in IE (#11
23362336
});
23372337
});
23382338

2339+
test( "jQuery.domManip - no side effect because of ajaxSetup or global events (#11264)", function() {
2340+
expect( 1 );
2341+
2342+
jQuery.ajaxSetup({
2343+
type: "POST"
2344+
});
2345+
2346+
jQuery( document ).bind( "ajaxStart ajaxStop", function() {
2347+
ok( false, "Global event triggered" );
2348+
});
2349+
2350+
jQuery( "#qunit-fixture" ).append( "<script src='data/evalScript.php'></script>" );
2351+
2352+
jQuery( document ).unbind( "ajaxStart ajaxStop" );
2353+
2354+
jQuery.ajaxSetup({
2355+
type: "GET"
2356+
});
2357+
});
2358+
23392359
test("jQuery.ajax - active counter", function() {
23402360
ok( jQuery.active == 0, "ajax active counter should be zero: " + jQuery.active );
23412361
});

0 commit comments

Comments
 (0)