Skip to content
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

Date properties seem to be reassigned / trigger reactivity #8225

Closed
jacobmischka opened this issue Jan 24, 2023 · 2 comments
Closed

Date properties seem to be reassigned / trigger reactivity #8225

jacobmischka opened this issue Jan 24, 2023 · 2 comments

Comments

@jacobmischka
Copy link
Contributor

jacobmischka commented Jan 24, 2023

Describe the bug

If a component accepts a date property, and a parent component binds that component, then the parent component will think that the property has changed even if the child component performs no changes.

The same doesn't happen if the property is a primitive value like a number, boolean, or string.

Reproduction

https://svelte.dev/repl/8ead02e349fa4884835654f809a77543?version=3.55.1

App.svelte:

<script>
	import DateComponent from './DateComponent.svelte';
	let date = new Date();
	let num = date.valueOf();
	let string = date.toString();
	
	$: console.log("date assigned:", date);
	$: console.log("num assigned:", num);
	$: console.log("string assigned:", string);
</script>

<DateComponent bind:value={date} />
<DateComponent bind:value={num} />
<DateComponent bind:value={string} />

DateComponent.svelte:

<script>
        export let value;
</script>

<pre>value: {value}</pre>

Logs

"date assigned:"    2023-01-24T22:25:16.391Z

    "num assigned:"    1674599116391

    "string assigned:"    "Tue Jan 24 2023 16:25:16 GMT-0600 (Central Standard Time)"

    "date assigned:"    2023-01-24T22:25:16.391Z

System Info

Tested solely in REPL for the purposes of this reproduction, version=3.55.1. Tested with both Firefox and Chrome.

Severity

annoyance

@Prinzhorn
Copy link
Contributor

Duplicate of #5689. It was briefly fixed in 3.54.0 but had to be reverted.

@jacobmischka
Copy link
Contributor Author

Closing in favor of #5689, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants