Skip to content

Commit

Permalink
Fixes #11264 or rather seriously limits the risk of global ajaxSettin…
Browse files Browse the repository at this point in the history
…gs screwing with script loading in domManip. Gotta love globals and sneaky dependencies. Unit test added.
  • Loading branch information
jaubourg committed Mar 7, 2012
1 parent 484cea1 commit d3fad51
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/manipulation.js
Expand Up @@ -351,6 +351,8 @@ jQuery.fn.extend({
jQuery.each( scripts, function( i, elem ) {
if ( elem.src ) {
jQuery.ajax({
type: "GET",
global: false,
url: elem.src,
async: false,
dataType: "script"
Expand Down
1 change: 1 addition & 0 deletions test/data/evalScript.php
@@ -0,0 +1 @@
ok( "<?php echo $_SERVER['REQUEST_METHOD'] ?>" === "GET", "request method is <?php echo $_SERVER['REQUEST_METHOD'] ?>" );
20 changes: 20 additions & 0 deletions test/unit/ajax.js
Expand Up @@ -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() {
ok( jQuery.active == 0, "ajax active counter should be zero: " + jQuery.active );
});
Expand Down

0 comments on commit d3fad51

Please sign in to comment.