exports/global: Do not attach global variables for most CommonJS environments

For CommonJS environments where the global already has a document, it is expected
that if a global is needed, the user can attach the global.

Fixes #14645.
This commit is contained in:
Timmy Willison 2013-12-20 18:39:16 -05:00
parent bf6c95a81e
commit 36f00d0771
2 changed files with 8 additions and 5 deletions

View File

@ -1,6 +1,7 @@
define([ define([
"../core" "../core",
], function( jQuery ) { "../var/strundefined"
], function( jQuery, strundefined ) {
var var
// Map over jQuery in case of overwrite // Map over jQuery in case of overwrite
@ -24,6 +25,8 @@ jQuery.noConflict = function( deep ) {
// Expose jQuery and $ identifiers, even in // Expose jQuery and $ identifiers, even in
// AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557) // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
// and CommonJS for browser emulators (#13566) // and CommonJS for browser emulators (#13566)
window.jQuery = window.$ = jQuery; if ( typeof noGlobal === strundefined ) {
window.jQuery = window.$ = jQuery;
}
}); });

View File

@ -23,7 +23,7 @@
// e.g. var jQuery = require("jquery")(window); // e.g. var jQuery = require("jquery")(window);
// See ticket #14549 for more info // See ticket #14549 for more info
module.exports = global.document ? module.exports = global.document ?
factory( global ) : factory( global, true ) :
function( w ) { function( w ) {
if ( !w.document ) { if ( !w.document ) {
throw new Error( "jQuery requires a window with a document" ); throw new Error( "jQuery requires a window with a document" );
@ -35,7 +35,7 @@
} }
// Pass this, window may not be defined yet // Pass this, window may not be defined yet
}(this, function( window ) { }(this, function( window, noGlobal ) {
// Can't do this because several apps including ASP.NET trace // Can't do this because several apps including ASP.NET trace
// the stack via arguments.caller.callee and Firefox dies if // the stack via arguments.caller.callee and Firefox dies if