Merge pull request #3428 from sveltejs/gh-3322

allow slots to have missing props in SSR
pull/3437/head
Rich Harris 5 years ago committed by GitHub
commit ee1fa87c75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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