-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
Data in Task
and TasksDate
are accidentally mutable - dates can be edited unintentionally
#2866
Comments
I've committed the tests in description above: 3db9d43. |
Task
and TasksDate
are accidentally not immutable - dates can be edited unintenionallyTask
and TasksDate
are accidentally mutable - dates can be edited unintenionally
I discovered today that the 'moment.js Project Status' page specifically mentions this:
|
See also this issue, where a user was bitten by this issue: |
Task
and TasksDate
are accidentally mutable - dates can be edited unintenionallyTask
and TasksDate
are accidentally mutable - dates can be edited unintentionally
Whilst looking at this, consider the recommendations in: |
Please check that this issue hasn't been reported before.
Expected Behavior
That a user should be able to do
task.due.moment?.startOf('week')
or similar ingroup by function
, and not modify the stored date in the task.Cause: https://momentjscom.readthedocs.io/en/latest/moment/03-manipulating/03-start-of/
There may be other methods of
Moment
that mutate the stored data.I suspect that this may be the underlying cause of:
Based on the tests below, I expect that doing so would modify the stored data in
Task
, even thoughTask
is designed to be immutable.Also, that these tests should pass:
Current behaviour
The above tests fail, and so are marked as
.failing
.Steps to reproduce
See the tests above, which I will commit.
Which Operating Systems are you using?
Obsidian Version
1.6.1
Tasks Plugin Version
7.3.0
Checks
Possible solution
The code should always clone moment objects before returning them.
See https://momentjscom.readthedocs.io/en/latest/moment/01-parsing/12-moment-clone/
The text was updated successfully, but these errors were encountered: