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

Assigning a prop to an imported object, breaks initial run of reactive statements #4555

Closed
jakobrosenberg opened this issue Mar 14, 2020 · 2 comments · Fixed by #4713
Closed
Labels

Comments

@jakobrosenberg
Copy link

jakobrosenberg commented Mar 14, 2020

Describe the bug
Imported objects don't work in reactive statements if there's an assignment to the object.

To Reproduce
https://svelte.dev/repl/5f4423eaf63644dfa71578997b0b0d4c?version=3.19.2

Expected behavior
The reactive statement should be executed on load

Severity
Severe since the bug doesn't show any warnings and thus can break apps without a way to track it down.

Additional context
Reassigning the imported object fixes the bug:

  import {obj as importedObj} from './obj.js'
  const obj = importedObj
@jakobrosenberg jakobrosenberg changed the title Assigning a prop to a proxied object, breaks its functions in reactive statements Assigning a prop to an imported object, breaks initial run of reactive statements Mar 14, 2020
@Conduitry Conduitry added the bug label Mar 14, 2020
@pushkine
Copy link
Contributor

here is another repl of the bug
https://svelte.dev/repl/41ada46cf7e04922852fe34a0b32582d?version=3.20.1

here is a test + bad fix that puts every import into ctx
https://github.com/pushkine/svelte/tree/object-ext

the fix requires to check that

  • the object is mutated locally
  • some local state depends on it

I'm not familiar enough with the structure to do that myself

@Conduitry
Copy link
Member

This has been fixed in 3.22.0 - https://svelte.dev/repl/5f4423eaf63644dfa71578997b0b0d4c?version=3.22.0

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

Successfully merging a pull request may close this issue.

3 participants