Merge pull request #3380 from Conduitry/gh-3185

generate valid code when spreading literal into props
pull/3394/head
Rich Harris 5 years ago committed by GitHub
commit f26a15fd98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -220,9 +220,9 @@ export default class InlineComponentWrapper extends Wrapper {
const conditions = Array.from(all_dependencies).map(dep => `changed.${dep}`).join(' || '); const conditions = Array.from(all_dependencies).map(dep => `changed.${dep}`).join(' || ');
updates.push(deindent` updates.push(deindent`
var ${name_changes} = ${all_dependencies.size === 1 ? `${conditions}` : `(${conditions})`} ? @get_spread_update(${levels}, [ var ${name_changes} = ${conditions ? `(${conditions}) ? @get_spread_update(${levels}, [
${changes.join(',\n')} ${changes.join(',\n')}
]) : {}; ]) : {}` : '{}'};
`); `);
} else { } else {
this.node.attributes this.node.attributes

@ -0,0 +1,5 @@
<script>
export let foo;
</script>
<p>foo: {foo}</p>

@ -0,0 +1,5 @@
export default {
html: `
<div><p>foo: bar</p></div>
`
};

@ -0,0 +1,7 @@
<script>
import Widget from './Widget.svelte';
</script>
<div>
<Widget {...{ foo: 'bar' }}/>
</div>
Loading…
Cancel
Save