From 6be176df2f760e314023e3ddbf42b45fc5575dbb Mon Sep 17 00:00:00 2001 From: Nic Polumeyv Date: Fri, 11 Sep 2026 07:24:55 -0400 Subject: [PATCH] fix: resolve the fallback of an each block in the enclosing scope (#18803) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In `phases/scope.js`, `EachBlock` visits `node.fallback` with the block's own scope, so `{:else}` resolves the loop's name to the each context. With `let item = $state('outer')` outside and `{#each items as item}…{:else}', + + test({ assert, target }) { + const button = target.querySelector('button'); + flushSync(() => { + button?.click(); + }); + assert.htmlEqual(target.innerHTML, ''); + } +}); diff --git a/packages/svelte/tests/runtime-runes/samples/each-fallback-outer-scope/main.svelte b/packages/svelte/tests/runtime-runes/samples/each-fallback-outer-scope/main.svelte new file mode 100644 index 0000000000..7ebb37e2f7 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/each-fallback-outer-scope/main.svelte @@ -0,0 +1,10 @@ + + +{#each items as item} +

{item}

+{:else} + +{/each}