Closed jarcoal closed 7 years ago
Great catch, thanks!
Can you please also add a unit test that fails without this change to make sure we don't introduce any regressions in the future?
Looks like the default preprocessor actually does a clone here.
Do you think this is still a worthwhile patch given that developers with custom preprocessors might hit the issue?
Did you verify the calling moment()
on that line actually returns a new object?
I believe that if the preprocessDate()
method already takes care of cloning the object, we don't need to clone it again in the other preprocessors. Thoughts?
Currently the amTimezone filter mutates the moment object before returning it. This creates all sorts of subtle bugs if that moment is used later.
This patch clones the moment before applying the timezone to prevent this from happening.