Skip to content

Commit

Permalink
using cloneDate
Browse files Browse the repository at this point in the history
  • Loading branch information
asdfghjkkl11 committed Oct 31, 2024
1 parent 638f385 commit 0017f71
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib/DateInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
/** Default date to display in picker before value is assigned */
const defaultDate = new Date()
function cloneDate(d: Date) {
return new Date(d.getTime())
}
// inner date value store for preventing value updates (and also
// text updates as a result) when date is unchanged
const innerStore = writable(null as Date | null)
Expand All @@ -27,8 +31,7 @@
innerStore.set(null)
value = date
} else if (date.getTime() !== $innerStore?.getTime()) {
const copyDate = new Date(date);
innerStore.set(copyDate)
innerStore.set(cloneDate(date))
value = date
}
},
Expand Down

0 comments on commit 0017f71

Please sign in to comment.