mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
squash! Set attributes all at once, src last
This commit is contained in:
parent
1f4375a342
commit
dc48b11e0c
@ -48,19 +48,16 @@ jQuery.ajaxTransport( "script", function( s ) {
|
|||||||
var script, callback;
|
var script, callback;
|
||||||
return {
|
return {
|
||||||
send: function( _, complete ) {
|
send: function( _, complete ) {
|
||||||
script = jQuery( "<script>" ).prop( {
|
script = jQuery( "<script>" )
|
||||||
charset: s.scriptCharset,
|
.attr( s.scriptAttrs || {} )
|
||||||
src: s.url
|
.prop( { charset: s.scriptCharset, src: s.url } )
|
||||||
} ).attr( s.scriptAttrs || {} ).on(
|
.on( "load error", callback = function( evt ) {
|
||||||
"load error",
|
|
||||||
callback = function( evt ) {
|
|
||||||
script.remove();
|
script.remove();
|
||||||
callback = null;
|
callback = null;
|
||||||
if ( evt ) {
|
if ( evt ) {
|
||||||
complete( evt.type === "error" ? 404 : 200, evt.type );
|
complete( evt.type === "error" ? 404 : 200, evt.type );
|
||||||
}
|
}
|
||||||
}
|
} );
|
||||||
);
|
|
||||||
|
|
||||||
// Use native DOM manipulation to avoid our domManip AJAX trickery
|
// Use native DOM manipulation to avoid our domManip AJAX trickery
|
||||||
document.head.appendChild( script[ 0 ] );
|
document.head.appendChild( script[ 0 ] );
|
||||||
|
@ -91,15 +91,13 @@ QUnit.module( "ajax", {
|
|||||||
|
|
||||||
ajaxTest( "jQuery.ajax() - custom attributes for script tag", 4,
|
ajaxTest( "jQuery.ajax() - custom attributes for script tag", 4,
|
||||||
function( assert ) {
|
function( assert ) {
|
||||||
var nonceValue = "0123456789";
|
|
||||||
return {
|
return {
|
||||||
create: function( options ) {
|
create: function( options ) {
|
||||||
var xhr;
|
var xhr;
|
||||||
options.dataType = "script";
|
options.dataType = "script";
|
||||||
options.scriptAttrs = { id: "jquery-ajax-test", nonce: nonceValue };
|
options.scriptAttrs = { id: "jquery-ajax-test", async: "async" };
|
||||||
xhr = jQuery.ajax( url( "data/script.php?header=ecma" ), options );
|
xhr = jQuery.ajax( url( "mock.php?action=script" ), options );
|
||||||
// Ensure the script tag has the nonce attr on it
|
assert.equal( jQuery( "#jquery-ajax-test" ).attr( "async" ), "async", "attr value" );
|
||||||
assert.ok( nonceValue === jQuery( "#jquery-ajax-test" ).attr( "nonce" ), "nonce value" );
|
|
||||||
return xhr;
|
return xhr;
|
||||||
},
|
},
|
||||||
success: function() {
|
success: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user