snippet-work-cont
Simon Holthausen 6 months ago
parent 9be0fdd753
commit be3b08cbe5

@ -69,11 +69,13 @@ export function set_text(dom, value) {
* @param {null | ((anchor: Comment) => void)} fallback_fn
*/
export function slot(anchor, $$props, slot_name, slot_props, fallback_fn) {
var is_snippet = false;
var slot_fn = $$props.$$slots?.[slot_name];
if (slot_fn === true) {
if (slot_name === 'default') {
slot_fn = $$props.children;
} else {
is_snippet = true;
slot_fn = $$props[slot_name];
}
}
@ -83,7 +85,7 @@ export function slot(anchor, $$props, slot_name, slot_props, fallback_fn) {
fallback_fn(anchor);
}
} else {
slot_fn(anchor, slot_props);
slot_fn(anchor, is_snippet ? () => slot_props : slot_props);
}
}

@ -1,2 +1,2 @@
<p><slot /></p>
<p><slot name="named" /></p>
<p><slot name="named" foo="foo" /></p>

@ -1,5 +1,5 @@
import { test } from '../../test';
export default test({
html: `<p>Default</p> <p>Named</p>`
html: `<p>Default</p> <p>Named foo</p>`
});

@ -4,7 +4,7 @@
<Child>
Default
{#snippet named()}
Named
{#snippet named({ foo })}
Named {foo}
{/snippet}
</Child>

Loading…
Cancel
Save