From: Tate Johnson Date: Mon, 20 Jan 2014 04:59:09 +0000 (+1100) Subject: Change object construction to prevent Chrome v32 crashing. X-Git-Tag: 2.5.1~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=080c7313d4e328c49fd1e370f33b36a56f0c5f80;p=thirdparty%2Fmoment.git Change object construction to prevent Chrome v32 crashing. Suspected JS execution optimizations in v32 is causing the browser to throw "Aw, Snap". See https://github.com/moment/moment/issues/1423 --- diff --git a/moment.js b/moment.js index f0d575900..e314b30e2 100644 --- a/moment.js +++ b/moment.js @@ -1576,41 +1576,47 @@ } 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)