mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Core:Ajax: Align nonce & global with master, fix an AMD issue
This commit aligns the `3.x-stable` branch with `master` in two aspects:
1. It migrates the nonce module to return an object instead of a primitive
variable. This had to be changed on `master` as in ES modules you export
live read-only bindings to variables, meaning you can't increment the nonce
directly. Also, the way it was done so far was working differently in AMD & the
single built file - in the built file one nonce variable was declared, accessed
and incremented. In AMD mode separate instances were create for each module
that depend on the nonce module, creating unintended nonce clashes.
2. Whether the `noGlobal` parameter was set to `true` is now checked using the
typeof operator to align with `master`.
Closes gh-4612
Ref gh-4541
Ref d0ce00cdfa
This commit is contained in:
parent
3dedc3f2d4
commit
22bf701fe1
@ -610,7 +610,8 @@ jQuery.extend( {
|
||||
// Add or update anti-cache param if needed
|
||||
if ( s.cache === false ) {
|
||||
cacheURL = cacheURL.replace( rantiCache, "$1" );
|
||||
uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
|
||||
uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) +
|
||||
uncached;
|
||||
}
|
||||
|
||||
// Put hash and anti-cache on the URL that will be requested (gh-1732)
|
||||
|
@ -15,7 +15,7 @@ var oldCallbacks = [],
|
||||
jQuery.ajaxSetup( {
|
||||
jsonp: "callback",
|
||||
jsonpCallback: function() {
|
||||
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
|
||||
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) );
|
||||
this[ callback ] = true;
|
||||
return callback;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
define( function() {
|
||||
"use strict";
|
||||
|
||||
return Date.now();
|
||||
return { guid: Date.now() };
|
||||
} );
|
||||
|
@ -1,6 +1,6 @@
|
||||
define( [
|
||||
"../core"
|
||||
], function( jQuery, noGlobal ) {
|
||||
], function( jQuery ) {
|
||||
|
||||
"use strict";
|
||||
|
||||
@ -27,7 +27,7 @@ jQuery.noConflict = function( deep ) {
|
||||
// Expose jQuery and $ identifiers, even in AMD
|
||||
// (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
|
||||
// and CommonJS for browser emulators (#13566)
|
||||
if ( !noGlobal ) {
|
||||
if ( typeof noGlobal === "undefined" ) {
|
||||
window.jQuery = window.$ = jQuery;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user