uxsolutions / bootstrap-datepicker

A datepicker for twitter bootstrap (@twbs)
Apache License 2.0
12.66k stars 6.06k forks source link

defaultViewDate modify my input variable #2680

Open loverg-c opened 1 year ago

loverg-c commented 1 year ago

Expected behaviour

When i pass a date object as an input for the defaultViewDate, this variable should not be modified when i'm changing the viewDate by switching my view manually

Actual behaviour

My input variable is changed when i'm switching the view mode manually

Step to reproduce

Given I have a datepicker And I pass a Date variable as defaultViewDate option, When I open the datepicker And I click on the month view And I click on another month than my defaultViewDate Then my date variable has been changed

Datepicker version used

1.9.0

Example code

https://jsfiddle.net/g7r0ow4y/


I think its maybe related to this commit https://github.com/uxsolutions/bootstrap-datepicker/commit/8c99457dbdf206a393341a2924ed0afacc1364bd , because other case use a copy of the startDate (by doing a new Date), but not on this else.

(Maybe i'm wrong, i didn't investigate so much and i'm not used to js)