Describe the bug
It seems a value from a " let:" on a component with slots doesn't trigger an update when used as a prop on a slot... eg
<WithColourPicker let:colour>
<slot titlecolour={colour} />
</WithColourPicker>
changes that "WithColourPicker" makes to "colour" aren't causing the slot to rerender with new titlecolour.
To Reproduce
Working:
https://svelte.dev/repl/991c974902464e119edc540fd18a99cd?version=3.6.1
Broken:
https://svelte.dev/repl/991c974902464e119edc540fd18a99cd?version=3.7.0
Expected behavior
Expected:
In the repl, expected behaviour is that the heading colour changes and the text changes its wording to include the selected colour. (this can be seen in the 3.6.1 link)
What happens:
The text colour changes, but the wording doesn't change.
Severity
Svelte native uses nested slots like above in its rendering of List Views. This regression breaks svelte native :(
Additional context
Looking at generated code
in 3.7.0:
// ColouredTitle.svelte
const get_default_slot_changes = ({ colour }) => ({});
const get_default_slot_context = ({ colour }) => ({ titlecolour: colour });
p(changed, ctx) {
if (default_slot && default_slot.p && changed.$$scope) {
default_slot.p(get_slot_changes(default_slot_1, ctx, changed, get_default_slot_changes), get_slot_context(default_slot_1, ctx, get_default_slot_context));
}
}
whereas 3.6.1:
//ColouredTitle.svelte
const get_default_slot_changes = ({ colour }) => ({ titlecolour: colour });
const get_default_slot_context = ({ colour }) => ({ titlecolour: colour });
if (default_slot && default_slot.p && (changed.$$scope || changed.colour)) {
default_slot.p(get_slot_changes(default_slot_1, ctx, changed, get_default_slot_changes), get_slot_context(default_slot_1, ctx, get_default_slot_context));
}
Note that 3.6.1 considers changed.colour enough to update the slot where 3.7.0 doesn't consider this relevant.
Diagnosis
I think this happens because although the let variable is added to the dependencies for the InlineComponentWrapper https://github.com/sveltejs/svelte/commit/b2d9da3460f1794e342d7a0b0c04c32d8bbac6cd#diff-beaec73b844dfbe1d4a6ee6da477b182R165
They are ignored when processing the slot by this:
https://github.com/sveltejs/svelte/commit/b2d9da3460f1794e342d7a0b0c04c32d8bbac6cd#diff-5f78860f62364bc95ba513ae1fdfdc3dR88
But I am unsure of the correct fix
fixed in 3.7.1: https://svelte.dev/repl/991c974902464e119edc540fd18a99cd?version=3.7.1. thanks!
Thanks for the awesomely quick turnaround Rich
Most helpful comment
fixed in 3.7.1: https://svelte.dev/repl/991c974902464e119edc540fd18a99cd?version=3.7.1. thanks!