]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Make sure updateOffset on creation won't cause infinite recursion
authorIskren Chernev <iskren.chernev@gmail.com>
Sun, 28 Dec 2014 16:51:46 +0000 (18:51 +0200)
committerIskren Chernev <iskren.chernev@gmail.com>
Sun, 28 Dec 2014 16:51:46 +0000 (18:51 +0200)
moment.js

index 3507addac26ac0cb2338a44df75c9e65cfab2df5..bc476c38b704065c31a0bb814f1af494ccdb0015 100644 (file)
--- a/moment.js
+++ b/moment.js
 
         deprecations = {},
 
-        lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin'];
+        lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin'],
+
+        updateInProgress = false;
 
     // Pick the first defined of two or three arguments. dfl comes from
     // default.
         }
         copyConfig(this, config);
         this._d = new Date(+config._d);
-        if (moment.updateOffset) {
+        // Prevent infinite loop in case updateOffset creates new moment
+        // objects.
+        if (updateInProgress === false) {
+            updateInProgress = true;
             moment.updateOffset(this);
+            updateInProgress = false;
         }
     }