From d3fad51cad1f71bd20beba81b51552295721a5a5 Mon Sep 17 00:00:00 2001 From: jaubourg Date: Wed, 7 Mar 2012 16:54:05 +0100 Subject: 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. --- src/manipulation.js | 2 ++ test/data/evalScript.php | 1 + test/unit/ajax.js | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 test/data/evalScript.php diff --git a/src/manipulation.js b/src/manipulation.js index 0b42810da..2a3757904 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -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" diff --git a/test/data/evalScript.php b/test/data/evalScript.php new file mode 100644 index 000000000..ea9b8c55f --- /dev/null +++ b/test/data/evalScript.php @@ -0,0 +1 @@ +ok( "" === "GET", "request method is " ); \ No newline at end of file diff --git a/test/unit/ajax.js b/test/unit/ajax.js index cca457db1..163ba4f05 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -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( "" ); + + 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 ); }); -- cgit v1.2.3