Repository navigation
Conversation
Invalid moments were casting as 'null' (the string) Now they are properly casting as null (the literal)
There was a problem hiding this comment.
The comment should just show new Date(NaN).toJSON() === null. It's the JSON.stringify part that is confusing the issue.
There was a problem hiding this comment.
Updated, thanks for the reminder, didn't think that one through enough. Fixed in commit dafaba3
|
LGTM. Staging for 2.12.0 (unless @ichernev decides to do a 2.11.2). Thanks for your contribution! |
|
(seems silly to label a bug fix with "bug") :) |
|
Do we know why it was made a string in the first place? Seems like a really explicit decision in d4a1694 |
|
@icambron - The comment leads me to believe there was a misunderstanding between JSON.stringify(NaN) // "null"
JSON.stringify(null) // "null"
JSON.stringify('null') // ""null""
JSON.stringify(new Date(NaN)) // "null"
new Date(NaN).toJSON() // nullOur implementation should match the |
|
👍 |
|
Merged in 2255756 |
Fix toJSON casting of invalid moment
This is an attempt at solving issue #2886.
Invalid moments were casting as 'null' (the string)
Now they are properly casting as null (the literal)