mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Core: expose noConflict in AMD mode
- For compability reasons, we had already added the global in AMD mode, but without noConflict. This adds back noConflict to AMD (which fixes noConflict mode in the tests). Fixes gh-2930
This commit is contained in:
parent
560c0c6f99
commit
52e24471c8
@ -17,7 +17,6 @@ module.exports = function( grunt ) {
|
|||||||
read = function( fileName ) {
|
read = function( fileName ) {
|
||||||
return grunt.file.read( srcFolder + fileName );
|
return grunt.file.read( srcFolder + fileName );
|
||||||
},
|
},
|
||||||
globals = read( "exports/global.js" ),
|
|
||||||
wrapper = read( "wrapper.js" ).split( /\/\/ \@CODE\n\/\/[^\n]+/ ),
|
wrapper = read( "wrapper.js" ).split( /\/\/ \@CODE\n\/\/[^\n]+/ ),
|
||||||
config = {
|
config = {
|
||||||
baseUrl: "src",
|
baseUrl: "src",
|
||||||
@ -39,10 +38,7 @@ module.exports = function( grunt ) {
|
|||||||
skipSemiColonInsertion: true,
|
skipSemiColonInsertion: true,
|
||||||
wrap: {
|
wrap: {
|
||||||
start: wrapper[ 0 ].replace( /\/\*\s*eslint(?: |-).*\s*\*\/\n/, "" ),
|
start: wrapper[ 0 ].replace( /\/\*\s*eslint(?: |-).*\s*\*\/\n/, "" ),
|
||||||
end: globals.replace(
|
end: wrapper[ 1 ]
|
||||||
/\/\*\s*ExcludeStart\s*\*\/[\w\W]*?\/\*\s*ExcludeEnd\s*\*\//ig,
|
|
||||||
""
|
|
||||||
) + wrapper[ 1 ]
|
|
||||||
},
|
},
|
||||||
rawText: {},
|
rawText: {},
|
||||||
onBuildWrite: convert
|
onBuildWrite: convert
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
/* ExcludeStart */
|
define( [
|
||||||
|
"../core"
|
||||||
|
], function( jQuery, noGlobal ) {
|
||||||
|
|
||||||
// This file is included in a different way from all the others
|
"use strict";
|
||||||
// so the "use strict" pragma is not needed.
|
|
||||||
/* eslint strict: "off" */
|
|
||||||
|
|
||||||
/* ExcludeEnd */
|
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
||||||
@ -32,3 +30,5 @@ jQuery.noConflict = function( deep ) {
|
|||||||
if ( !noGlobal ) {
|
if ( !noGlobal ) {
|
||||||
window.jQuery = window.$ = jQuery;
|
window.jQuery = window.$ = jQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
5
src/jquery.js
vendored
5
src/jquery.js
vendored
@ -30,11 +30,12 @@ define( [
|
|||||||
"./offset",
|
"./offset",
|
||||||
"./dimensions",
|
"./dimensions",
|
||||||
"./deprecated",
|
"./deprecated",
|
||||||
"./exports/amd"
|
"./exports/amd",
|
||||||
|
"./exports/global"
|
||||||
], function( jQuery ) {
|
], function( jQuery ) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
return ( window.jQuery = window.$ = jQuery );
|
return jQuery;
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
@ -320,9 +320,7 @@ this.loadTests = function() {
|
|||||||
/**
|
/**
|
||||||
* Run in noConflict mode
|
* Run in noConflict mode
|
||||||
*/
|
*/
|
||||||
if ( jQuery.noConflict ) {
|
jQuery.noConflict();
|
||||||
jQuery.noConflict();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the TestSwarm listener if swarmURL is in the address.
|
// Load the TestSwarm listener if swarmURL is in the address.
|
||||||
if ( QUnit.isSwarm ) {
|
if ( QUnit.isSwarm ) {
|
||||||
|
@ -197,27 +197,24 @@ QUnit.test( "globalEval execution after script injection (#7862)", function( ass
|
|||||||
assert.ok( window.strictEvalTest - now < 500, "Code executed synchronously" );
|
assert.ok( window.strictEvalTest - now < 500, "Code executed synchronously" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// This is not run in AMD mode
|
QUnit.test( "noConflict", function( assert ) {
|
||||||
if ( jQuery.noConflict ) {
|
assert.expect( 7 );
|
||||||
QUnit.test( "noConflict", function( assert ) {
|
|
||||||
assert.expect( 7 );
|
|
||||||
|
|
||||||
var $$ = jQuery;
|
var $$ = jQuery;
|
||||||
|
|
||||||
assert.strictEqual( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" );
|
assert.strictEqual( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" );
|
||||||
assert.strictEqual( window[ "jQuery" ], $$, "Make sure jQuery wasn't touched." );
|
assert.strictEqual( window[ "jQuery" ], $$, "Make sure jQuery wasn't touched." );
|
||||||
assert.strictEqual( window[ "$" ], original$, "Make sure $ was reverted." );
|
assert.strictEqual( window[ "$" ], original$, "Make sure $ was reverted." );
|
||||||
|
|
||||||
jQuery = $ = $$;
|
jQuery = $ = $$;
|
||||||
|
|
||||||
assert.strictEqual( jQuery.noConflict( true ), $$, "noConflict returned the jQuery object" );
|
assert.strictEqual( jQuery.noConflict( true ), $$, "noConflict returned the jQuery object" );
|
||||||
assert.strictEqual( window[ "jQuery" ], originaljQuery, "Make sure jQuery was reverted." );
|
assert.strictEqual( window[ "jQuery" ], originaljQuery, "Make sure jQuery was reverted." );
|
||||||
assert.strictEqual( window[ "$" ], original$, "Make sure $ was reverted." );
|
assert.strictEqual( window[ "$" ], original$, "Make sure $ was reverted." );
|
||||||
assert.ok( $$().pushStack( [] ), "Make sure that jQuery still works." );
|
assert.ok( $$().pushStack( [] ), "Make sure that jQuery still works." );
|
||||||
|
|
||||||
window[ "jQuery" ] = jQuery = $$;
|
window[ "jQuery" ] = jQuery = $$;
|
||||||
} );
|
} );
|
||||||
}
|
|
||||||
|
|
||||||
QUnit.test( "trim", function( assert ) {
|
QUnit.test( "trim", function( assert ) {
|
||||||
assert.expect( 13 );
|
assert.expect( 13 );
|
||||||
|
Loading…
Reference in New Issue
Block a user