diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index 5aeff019bd7e..355ad0c423b9 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -72,7 +72,7 @@ export default class Component { stats: Stats; warnings: Warning[]; ignores: Set; - ignore_stack: Set[] = []; + ignore_stack: Array> = []; ast: Ast; source: string; diff --git a/src/compiler/compile/render_dom/wrappers/Slot.ts b/src/compiler/compile/render_dom/wrappers/Slot.ts index 4dd23277fb19..3585d273586d 100644 --- a/src/compiler/compile/render_dom/wrappers/Slot.ts +++ b/src/compiler/compile/render_dom/wrappers/Slot.ts @@ -84,6 +84,7 @@ export default class SlotWrapper extends Wrapper { }); const dynamic_dependencies = Array.from(attribute.dependencies).filter(name => { + if (this.node.scope.is_let(name)) return true; const variable = renderer.component.var_lookup.get(name); return is_dynamic(variable); }); @@ -105,7 +106,7 @@ export default class SlotWrapper extends Wrapper { } const slot = block.get_unique_name(`${sanitize(slot_name)}_slot`); - const slot_definition = block.get_unique_name(`${sanitize(slot_name)}_slot`); + const slot_definition = block.get_unique_name(`${sanitize(slot_name)}_slot_template`); block.builders.init.add_block(deindent` const ${slot_definition} = ctx.$$slots${quote_prop_if_necessary(slot_name)}; @@ -162,6 +163,7 @@ export default class SlotWrapper extends Wrapper { const dynamic_dependencies = Array.from(this.dependencies).filter(name => { if (name === '$$scope') return true; + if (this.node.scope.is_let(name)) return true; const variable = renderer.component.var_lookup.get(name); return is_dynamic(variable); }); @@ -171,7 +173,10 @@ export default class SlotWrapper extends Wrapper { block.builders.update.add_block(deindent` if (${slot} && ${slot}.p && ${update_conditions}) { - ${slot}.p(@get_slot_changes(${slot_definition}, ctx, changed, ${get_slot_changes}), @get_slot_context(${slot_definition}, ctx, ${get_slot_context})); + ${slot}.p( + @get_slot_changes(${slot_definition}, ctx, changed, ${get_slot_changes}), + @get_slot_context(${slot_definition}, ctx, ${get_slot_context}) + ); } `); diff --git a/test/runtime/samples/component-slot-let-f/A.svelte b/test/runtime/samples/component-slot-let-f/A.svelte new file mode 100644 index 000000000000..79428b13ecd8 --- /dev/null +++ b/test/runtime/samples/component-slot-let-f/A.svelte @@ -0,0 +1,9 @@ + + + + {reflected} + + \ No newline at end of file diff --git a/test/runtime/samples/component-slot-let-f/B.svelte b/test/runtime/samples/component-slot-let-f/B.svelte new file mode 100644 index 000000000000..7a8dc596ba63 --- /dev/null +++ b/test/runtime/samples/component-slot-let-f/B.svelte @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/test/runtime/samples/component-slot-let-f/_config.js b/test/runtime/samples/component-slot-let-f/_config.js new file mode 100644 index 000000000000..74de38be02cc --- /dev/null +++ b/test/runtime/samples/component-slot-let-f/_config.js @@ -0,0 +1,15 @@ +export default { + html: ` + 1 + 1 + `, + + async test({ assert, target, component }) { + component.x = 2; + + assert.htmlEqual(target.innerHTML, ` + 2 + 2 + `); + } +}; diff --git a/test/runtime/samples/component-slot-let-f/main.svelte b/test/runtime/samples/component-slot-let-f/main.svelte new file mode 100644 index 000000000000..71362d9b4e2b --- /dev/null +++ b/test/runtime/samples/component-slot-let-f/main.svelte @@ -0,0 +1,8 @@ + + + + {reflected} + \ No newline at end of file