From: Iskren Chernev Date: Fri, 4 Apr 2014 07:10:52 +0000 (-0700) Subject: Set AMD global before module definition X-Git-Tag: 2.6.0~11^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e4938e9021ca268575befd0ef6ca97cb980c8f7;p=thirdparty%2Fmoment.git Set AMD global before module definition --- diff --git a/moment.js b/moment.js index 152d0a7b9..e82227537 100644 --- a/moment.js +++ b/moment.js @@ -14,6 +14,7 @@ VERSION = "2.5.1", // the global-scope this is NOT the global object in Node.js globalScope = typeof global !== 'undefined' ? global : this, + oldGlobalMoment, round = Math.round, i, @@ -2431,6 +2432,7 @@ if (typeof ender !== 'undefined') { return; } + oldGlobalMoment = globalScope.moment; if (shouldDeprecate) { globalScope.moment = deprecate( "Accessing Moment through the global scope is " + @@ -2448,13 +2450,14 @@ makeGlobal(true); } else if (typeof define === "function" && define.amd) { define("moment", function (require, exports, module) { - if (module.config && module.config() && module.config().noGlobal !== true) { - // If user provided noGlobal, he is aware of global - makeGlobal(module.config().noGlobal === undefined); + if (module.config && module.config() && module.config().noGlobal === true) { + // release the global variable + globalScope.moment = oldGlobalMoment; } return moment; }); + makeGlobal(true); } else { makeGlobal(); }