Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Change object construction to prevent Chrome v32 crashing. #1429

Merged
merged 1 commit into from

2 participants

@tatey

We were getting reports that our website was crashing in Chrome. We were able to pinpoint it to moment.

Changing the config from a literal object to setting properties is ugly, but resolves the issue for us in production. Given how frequently Chrome is updated I suspect we'll be able to revert it once it's fixed upstream.

See #1423.

@tatey tatey Change object construction to prevent Chrome v32 crashing.
Suspected JS execution optimizations in v32 is causing the browser to
throw "Aw, Snap".

See moment#1423
080c731
@ichernev
Owner

Thank you for troubleshooting and patching this. Can you please submit and link a chrome bug for this?

@ichernev ichernev merged commit b92af0d into moment:develop

1 check passed

Details default The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 20, 2014
  1. @tatey

    Change object construction to prevent Chrome v32 crashing.

    tatey authored
    Suspected JS execution optimizations in v32 is causing the browser to
    throw "Aw, Snap".
    
    See moment#1423
This page is out of date. Refresh to see the latest.
Showing with 28 additions and 22 deletions.
  1. +28 −22 moment.js
View
50 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)
Something went wrong with that request. Please try again.