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 to a member expression in a reactive statement shouldn't auto-declare the variable #4212

Closed
Conduitry opened this issue Jan 5, 2020 · 1 comment · Fixed by #4213
Labels

Comments

@Conduitry
Copy link
Member

Describe the bug
A reactive assignment that looks like $: document.title = whatever; doesn't work, because the compiler (unhelpfully, in this case) auto-declares document for us, and - since that is now undefined - the assignment document.title = whatever; is a runtime error.

Logs
TypeError: document is undefined

To Reproduce

<script>
  $: document.title = 'foo';
</script>

Expected behavior
This should simply assign to the global document and not attempt to automatically declare it

Stacktraces

Information about your Svelte project:
Svelte 3.16.7 - independent of browser or bundler.

Severity
Moderate, probably. We do specifically mention this syntax in the docs, and it doesn't work.

Additional context
I believe this will simply be a matter of adjusting the logic here for when we bail out and decide we don't need to auto-declare the variable.

@Conduitry
Copy link
Member Author

This is fixed in 3.17.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.

1 participant