From 4e8e14cf9a4abe336531b507c31f9b2a3e496bcd Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 3 Jul 2019 17:27:03 -0400 Subject: [PATCH] WIP solution for #1340 --- .../compile/nodes/shared/Expression.ts | 4 +-- .../Nested.svelte | 9 +++++++ .../component-slot-let-in-binding/_config.js | 26 +++++++++++++++++++ .../component-slot-let-in-binding/main.svelte | 11 ++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 test/runtime/samples/component-slot-let-in-binding/Nested.svelte create mode 100644 test/runtime/samples/component-slot-let-in-binding/_config.js create mode 100644 test/runtime/samples/component-slot-let-in-binding/main.svelte diff --git a/src/compiler/compile/nodes/shared/Expression.ts b/src/compiler/compile/nodes/shared/Expression.ts index ee04f83b77..1c58044696 100644 --- a/src/compiler/compile/nodes/shared/Expression.ts +++ b/src/compiler/compile/nodes/shared/Expression.ts @@ -138,8 +138,8 @@ export default class Expression { } if (template_scope.is_let(name)) { - if (!function_expression) { - dependencies.add(name); + if (!function_expression) { // TODO should this be `!lazy` ? + contextual_dependencies.add(name); } } else if (template_scope.names.has(name)) { expression.uses_context = true; diff --git a/test/runtime/samples/component-slot-let-in-binding/Nested.svelte b/test/runtime/samples/component-slot-let-in-binding/Nested.svelte new file mode 100644 index 0000000000..96f7adcfc6 --- /dev/null +++ b/test/runtime/samples/component-slot-let-in-binding/Nested.svelte @@ -0,0 +1,9 @@ + + +
+ {#each items as item, index} + + {/each} +
\ No newline at end of file diff --git a/test/runtime/samples/component-slot-let-in-binding/_config.js b/test/runtime/samples/component-slot-let-in-binding/_config.js new file mode 100644 index 0000000000..41e77a9574 --- /dev/null +++ b/test/runtime/samples/component-slot-let-in-binding/_config.js @@ -0,0 +1,26 @@ +export default { + html: ` +
+ + + +
+ `, + + ssrHtml: ` +
+ + + +
+ `, + + async test({ assert, component, target, window }) { + const inputs = target.querySelectorAll('input'); + + inputs[2].value = 'd'; + await inputs[2].dispatchEvent(new window.Event('input')); + + assert.deepEqual(component.letters, ['a', 'b', 'd']); + } +}; diff --git a/test/runtime/samples/component-slot-let-in-binding/main.svelte b/test/runtime/samples/component-slot-let-in-binding/main.svelte new file mode 100644 index 0000000000..89531bf236 --- /dev/null +++ b/test/runtime/samples/component-slot-let-in-binding/main.svelte @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file