diff options
-rw-r--r-- | src/ajax/script.js | 13 | ||||
-rw-r--r-- | test/unit/ajax.js | 8 |
2 files changed, 8 insertions, 13 deletions
diff --git a/src/ajax/script.js b/src/ajax/script.js index 292627f7e..410c82cab 100644 --- a/src/ajax/script.js +++ b/src/ajax/script.js @@ -48,19 +48,16 @@ jQuery.ajaxTransport( "script", function( s ) { var script, callback; return { send: function( _, complete ) { - script = jQuery( "<script>" ).prop( { - charset: s.scriptCharset, - src: s.url - } ).attr( s.scriptAttrs || {} ).on( - "load error", - callback = function( evt ) { + script = jQuery( "<script>" ) + .attr( s.scriptAttrs || {} ) + .prop( { charset: s.scriptCharset, src: s.url } ) + .on( "load error", callback = function( evt ) { script.remove(); callback = null; if ( evt ) { complete( evt.type === "error" ? 404 : 200, evt.type ); } - } - ); + } ); // Use native DOM manipulation to avoid our domManip AJAX trickery document.head.appendChild( script[ 0 ] ); diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 8a13810fc..72a4e7215 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -91,15 +91,13 @@ QUnit.module( "ajax", { ajaxTest( "jQuery.ajax() - custom attributes for script tag", 4, function( assert ) { - var nonceValue = "0123456789"; return { create: function( options ) { var xhr; options.dataType = "script"; - options.scriptAttrs = { id: "jquery-ajax-test", nonce: nonceValue }; - xhr = jQuery.ajax( url( "data/script.php?header=ecma" ), options ); - // Ensure the script tag has the nonce attr on it - assert.ok( nonceValue === jQuery( "#jquery-ajax-test" ).attr( "nonce" ), "nonce value" ); + options.scriptAttrs = { id: "jquery-ajax-test", async: "async" }; + xhr = jQuery.ajax( url( "mock.php?action=script" ), options ); + assert.equal( jQuery( "#jquery-ajax-test" ).attr( "async" ), "async", "attr value" ); return xhr; }, success: function() { |