diff --git a/src/compiler/compile/render_dom/Renderer.ts b/src/compiler/compile/render_dom/Renderer.ts index 842bd90f0a..27895e2f9c 100644 --- a/src/compiler/compile/render_dom/Renderer.ts +++ b/src/compiler/compile/render_dom/Renderer.ts @@ -167,15 +167,23 @@ export default class Renderer { const variable = this.component.var_lookup.get(head); - // TODO this feels woolly. might encounter false positive - // if each context shadows top-level var + // // TODO this feels woolly. might encounter false positive + // // if each context shadows top-level var + // if (variable) { + // this.component.add_reference(name); // TODO we can probably remove most other occurrences of this + + // if (!variable.hoistable) { + // head = x`#ctx[${i}]`; + // } + // } else if (i !== undefined) { + // head = x`#ctx[${i}]`; + // } + if (variable) { this.component.add_reference(name); // TODO we can probably remove most other occurrences of this + } - if (!variable.hoistable) { - head = x`#ctx[${i}]`; - } - } else if (i !== undefined) { + if (i !== undefined) { head = x`#ctx[${i}]`; } diff --git a/test/runtime/samples/each-block-scope-shadow/_config.js b/test/runtime/samples/each-block-scope-shadow/_config.js index 8005bc93d5..dff254a7c4 100644 --- a/test/runtime/samples/each-block-scope-shadow/_config.js +++ b/test/runtime/samples/each-block-scope-shadow/_config.js @@ -1,3 +1,3 @@ export default { - html: '(alpaca)(baboon)(capybara)' + html: '(alpaca)(baboon)(capybara) (lemur)' }; diff --git a/test/runtime/samples/each-block-scope-shadow/main.svelte b/test/runtime/samples/each-block-scope-shadow/main.svelte index b6c256e14f..645538a125 100644 --- a/test/runtime/samples/each-block-scope-shadow/main.svelte +++ b/test/runtime/samples/each-block-scope-shadow/main.svelte @@ -2,6 +2,8 @@ ({animal}) {/each} +({animal}) +