allow slots to have missing props in SSR - fixes #3322

pull/3428/head
Rich Harris 5 years ago
parent 1bb0728a5c
commit 07932da548

@ -8,7 +8,7 @@ export default function(node: Slot, renderer: Renderer, options: RenderOptions)
const slot_data = get_slot_data(node.values, true);
const arg = slot_data.length > 0 ? `{ ${slot_data.join(', ')} }` : '';
const arg = slot_data.length > 0 ? `{ ${slot_data.join(', ')} }` : '{}';
renderer.append(`\${$$slots${prop} ? $$slots${prop}(${arg}) : \``);

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

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

@ -0,0 +1,10 @@
<script>
import Foo from './Foo.svelte';
import Bar from './Bar.svelte';
const things = { '1': 'one' };
</script>
<Foo let:id>
<Bar thing={things[id]}/>
</Foo>
Loading…
Cancel
Save