]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Change object construction to prevent Chrome v32 crashing. 1429/head
authorTate Johnson <tate@tatey.com>
Mon, 20 Jan 2014 04:59:09 +0000 (15:59 +1100)
committerTate Johnson <tate@tatey.com>
Mon, 20 Jan 2014 05:07:19 +0000 (16:07 +1100)
Suspected JS execution optimizations in v32 is causing the browser to
throw "Aw, Snap".

See https://github.com/moment/moment/issues/1423

moment.js

index f0d575900254533b2d9258786ffdd9644d4e4638..e314b30e25d426067d3c65cdbfa6812126fdc2a7 100644 (file)
--- a/moment.js
+++ b/moment.js
     }
 
     moment = function (input, format, lang, strict) {
+        var c;
+
         if (typeof(lang) === "boolean") {
             strict = lang;
             lang = undefined;
         }
-        return makeMoment({
-            _isAMomentObject: true,
-            _i : input,
-            _f : format,
-            _l : lang,
-            _strict : strict,
-            _isUTC : false,
-            _pf : defaultParsingFlags()
-        });
+        // object construction must be done this way.
+        // https://github.com/moment/moment/issues/1423
+        c = {};
+        c._isAMomentObject = true;
+        c._i = input;
+        c._f = format;
+        c._l = lang;
+        c._strict = strict;
+        c._isUTC = false;
+        c._pf = defaultParsingFlags();
+
+        return makeMoment(c);
     };
 
     // creating with utc
     moment.utc = function (input, format, lang, strict) {
-        var m;
+        var c;
 
         if (typeof(lang) === "boolean") {
             strict = lang;
             lang = undefined;
         }
-        m = makeMoment({
-            _isAMomentObject: true,
-            _useUTC : true,
-            _isUTC : true,
-            _l : lang,
-            _i : input,
-            _f : format,
-            _strict : strict,
-            _pf : defaultParsingFlags()
-        }).utc();
-
-        return m;
+        // object construction must be done this way.
+        // https://github.com/moment/moment/issues/1423
+        c = {};
+        c._isAMomentObject = true;
+        c._useUTC = true;
+        c._isUTC = true;
+        c._l = lang;
+        c._i = input;
+        c._f = format;
+        c._strict = strict;
+        c._pf = defaultParsingFlags();
+
+        return makeMoment(c).utc();
     };
 
     // creating with unix timestamp (in seconds)