generate valid code when spreading literal into props (#3185)

pull/3380/head
Conduitry 5 years ago
parent 2ef004e324
commit 5b77b744ce

@ -220,9 +220,9 @@ export default class InlineComponentWrapper extends Wrapper {
const conditions = Array.from(all_dependencies).map(dep => `changed.${dep}`).join(' || ');
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')}
]) : {};
]) : {}` : '{}'};
`);
} else {
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