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

Why is this object re-assigned? #54

Open
frederikhors opened this issue Jan 24, 2023 · 4 comments
Open

Why is this object re-assigned? #54

frederikhors opened this issue Jan 24, 2023 · 4 comments
Assignees
Labels
upstream Not actually an issue with this package

Comments

@frederikhors
Copy link
Contributor

REPL: https://svelte.dev/repl/953050f84c9d4f528ecfaaaf50defbbf?version=3.55.1

Using the below code I found that the first team is re-assigned, the second nope (see the console).

Why?

I expect to not get re-assigned when the date is already present.

This may seem negligible, but when there are 30+ components on a page it is not at all (performances).

<script>
  import Flatpickr from './flatpickr.svelte';

  // this assigns team 2 times
  let team = {id: "1", start_date: new Date()};

  // this not
  // let team = {id: "1"};

  $: console.log("team assigned:", team);
</script>
@jacobmischka
Copy link
Owner

I don't think we're doing anything that should cause this, it seems like svelte is doing this on its own somehow. This seems to be a bug in svelte: date properties seem to be reassigned even though they aren't changed at all.

See this example, which doesn't use Flatpickr at all, and does no prop modification whatsoever: https://svelte.dev/repl/8ead02e349fa4884835654f809a77543?version=3.55.1

@frederikhors
Copy link
Contributor Author

Wow! We found a bug!

Would you mind open an issue on https://github.com/sveltejs/svelte/issues?

@jacobmischka
Copy link
Owner

I did: sveltejs/svelte#8225

@jacobmischka
Copy link
Owner

It seems like this is a known bug that might not be fixed until a new major released based on what I gathered from the comments there: sveltejs/svelte#5689

@jacobmischka jacobmischka self-assigned this Jan 25, 2023
@jacobmischka jacobmischka added the upstream Not actually an issue with this package label Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Not actually an issue with this package
Projects
None yet
Development

No branches or pull requests

2 participants