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

Fix non-object value of spread attributes variable #3306

Merged
merged 3 commits into from
Sep 9, 2019

Conversation

cvlab
Copy link
Contributor

@cvlab cvlab commented Jul 28, 2019

Fixes first part of #2282

Why:
({ ...b }) is equivalent to (_extends({}, b))

In svelte
({ ...b }) is equivalent to (_extends(b))

Bug REPL:
https://svelte.dev/repl/b76b676843774932b0c764293ff00c48?version=3.6.9

<script>
	import Component from './Component.svelte'
	let props = { foo: 'lol' }
	
	setTimeout(() => {
		props = undefined
	})
</script>

<Component { ...props } />

Component.svelte

{$$props.foo}

$$props.foo is 'lol' even if props is already undefined

In case of static 'ObjectExpression'

<Component { ...{ foo: 'lol' } } />

{ foo: 'lol' } will not be checked at runtime if it's an object or not.

@cvlab
Copy link
Contributor Author

cvlab commented Aug 5, 2019

  • Modified mr to fix possible side effects
  • Combined tests

@Rich-Harris Rich-Harris merged commit dc47fc7 into sveltejs:master Sep 9, 2019
@Rich-Harris
Copy link
Member

Thank you! Apologies for the long wait

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

Successfully merging this pull request may close these issues.

2 participants