props-bindable
Simon Holthausen 8 months ago
parent e98c242d2d
commit 7557c8f756

@ -2218,7 +2218,8 @@ export function server_component(analysis, options) {
});
}
// If the component binds to a child, we need to put the template in a loop and repeat until bindings are stable
// If the component binds to a child, we need to put the template in a loop and repeat until legacy bindings are stable.
// We can remove this once the legacy syntax is gone.
if (analysis.uses_component_bindings) {
template.body = [
b.let('$$settled', b.true),
@ -2267,6 +2268,8 @@ export function server_component(analysis, options) {
props.push(b.init(alias ?? name, b.id(name)));
}
if (props.length > 0) {
// This has no effect in runes mode other than throwing an error when someone passes
// undefined to a binding that has a default value.
template.body.push(b.stmt(b.call('$.bind_props', b.id('$$props'), b.object(props))));
}

@ -588,8 +588,8 @@ export function sanitize_slots(props) {
}
/**
* If the prop has a fallback and is bound in the parent component,
* propagate the fallback value upwards.
* Legacy mode: If the prop has a fallback and is bound in the
* parent component, propagate the fallback value upwards.
* @param {Record<string, unknown>} props_parent
* @param {Record<string, unknown>} props_now
*/

@ -11,6 +11,5 @@ export default function Svelte_element($$payload, $$props) {
$$payload.out += `${anchor}`;
if (tag) $.element($$payload, tag, () => {}, () => {});
$$payload.out += `${anchor}`;
$.bind_props($$props, { tag });
$.pop();
}
Loading…
Cancel
Save