From 9e4938e9021ca268575befd0ef6ca97cb980c8f7 Mon Sep 17 00:00:00 2001 From: Iskren Chernev Date: Fri, 4 Apr 2014 00:10:52 -0700 Subject: [PATCH] Set AMD global before module definition --- moment.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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(); } -- 2.47.2