]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Set AMD global before module definition 1590/head
authorIskren Chernev <iskren.chernev@gmail.com>
Fri, 4 Apr 2014 07:10:52 +0000 (00:10 -0700)
committerIskren Chernev <iskren.chernev@gmail.com>
Fri, 4 Apr 2014 07:10:52 +0000 (00:10 -0700)
moment.js

index 152d0a7b9564e9d4dca91f624d5ebdcd5b2f3b50..e8222753792b3a25e970308972f30d9daef62d4c 100644 (file)
--- 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,
 
         if (typeof ender !== 'undefined') {
             return;
         }
+        oldGlobalMoment = globalScope.moment;
         if (shouldDeprecate) {
             globalScope.moment = deprecate(
                     "Accessing Moment through the global scope is " +
         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();
     }