Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle wrongly cloned moments #1417

Merged
merged 5 commits into from
Jan 14, 2014

Conversation

ichernev
Copy link
Contributor

This is in response to #1404

  • detect moment objects that were cloned with something like _.extend({}, moment()) as isMoment-s
  • properly clone them and produce orthodox moment objects

Please interested parties (@chilversc, @mattbrooks2010, @RomanDidenko) -- test on knockout, or whatever fancy libraries you happen to use if it works fine with them.

@RomanDidenko
Copy link

I've tested changes on my functionality and had no issues anymore.

Thanks for the commit.

@mattbrooks2010
Copy link

I tested these changes using Knockout's ko.toJSON(...). The following works:

ko.toJSON(moment());

However, the following still results in the same RangeError as before:

ko.toJSON(moment.utc());

I've included the call stack in case it is any help.

RangeError: Maximum call stack size exceeded
    at moment (RangeError: Maximum call stack size exceeded
    at moment (moment.js:1576:9)
    at Object.extend.clone (moment.js:1756:20)
    at Object.extend.toString (moment.js:1768:25)
    at RegExp.exec (native)
    at makeDateFromInput (moment.js:1403:39)
    at makeMoment (moment.js:1565:13)
    at moment (moment.js:1576:16)
    at Object.extend.clone (moment.js:1756:20)
    at Object.extend.toString (moment.js:1768:25)
    at RegExp.exec (native) moment.js:1576:9)
    at Object.extend.clone (moment.js:1756:20)
    at Object.extend.toString (moment.js:1768:25)
    at RegExp.exec (native)
    at makeDateFromInput (moment.js:1403:39)
    at makeMoment (moment.js:1565:13)
    at moment (moment.js:1576:16)
    at Object.extend.clone (moment.js:1756:20)
    at Object.extend.toString (moment.js:1768:25)
    at RegExp.exec (native) 

@ichernev
Copy link
Contributor Author

@mattbrooks2010 yeah. I missed moment.utc. Now it works, I tested with ko and added tests.

@mattbrooks2010
Copy link

Confirmed - thank you. Do you know when a release will be available via NuGet?

icambron added a commit that referenced this pull request Jan 14, 2014
@icambron icambron merged commit b0a23c9 into moment:develop Jan 14, 2014
@icambron
Copy link
Member

Looks great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants