🌐 AI搜索 & 代理 主页
Skip to content

Commit dc48b11

Browse files
committed
squash! Set attributes all at once, src last
1 parent 1f4375a commit dc48b11

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

src/ajax/script.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,16 @@ jQuery.ajaxTransport( "script", function( s ) {
4848
var script, callback;
4949
return {
5050
send: function( _, complete ) {
51-
script = jQuery( "<script>" ).prop( {
52-
charset: s.scriptCharset,
53-
src: s.url
54-
} ).attr( s.scriptAttrs || {} ).on(
55-
"load error",
56-
callback = function( evt ) {
51+
script = jQuery( "<script>" )
52+
.attr( s.scriptAttrs || {} )
53+
.prop( { charset: s.scriptCharset, src: s.url } )
54+
.on( "load error", callback = function( evt ) {
5755
script.remove();
5856
callback = null;
5957
if ( evt ) {
6058
complete( evt.type === "error" ? 404 : 200, evt.type );
6159
}
62-
}
63-
);
60+
} );
6461

6562
// Use native DOM manipulation to avoid our domManip AJAX trickery
6663
document.head.appendChild( script[ 0 ] );

test/unit/ajax.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,13 @@ QUnit.module( "ajax", {
9191

9292
ajaxTest( "jQuery.ajax() - custom attributes for script tag", 4,
9393
function( assert ) {
94-
var nonceValue = "0123456789";
9594
return {
9695
create: function( options ) {
9796
var xhr;
9897
options.dataType = "script";
99-
options.scriptAttrs = { id: "jquery-ajax-test", nonce: nonceValue };
100-
xhr = jQuery.ajax( url( "data/script.php?header=ecma" ), options );
101-
// Ensure the script tag has the nonce attr on it
102-
assert.ok( nonceValue === jQuery( "#jquery-ajax-test" ).attr( "nonce" ), "nonce value" );
98+
options.scriptAttrs = { id: "jquery-ajax-test", async: "async" };
99+
xhr = jQuery.ajax( url( "mock.php?action=script" ), options );
100+
assert.equal( jQuery( "#jquery-ajax-test" ).attr( "async" ), "async", "attr value" );
103101
return xhr;
104102
},
105103
success: function() {

0 commit comments

Comments
 (0)