From a199e5a104f77da056df195dfc192c9cd7eb1666 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 21 Mar 2024 16:03:05 -0400 Subject: [PATCH] explain elseif locality --- .../3-transform/client/visitors/template.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js index d5aa49b5b9..6f956a230d 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js @@ -2583,7 +2583,27 @@ export const template_visitors = { ]; if (node.elseif) { - // the additional effect layer shouldn't affect local transitions + // We treat this... + // + // {#if x} + // ... + // {:else} + // {#if y} + //
...
+ // {/if} + // {/if} + // + // ...slightly differently to this... + // + // {#if x} + // ... + // {:else if y} + //
...
+ // {/if} + // + // ...even though they're logically equivalent. In the first case, the + // transition will only play when `y` changes, but in the second it + // should play when `x` or `y` change — both are considered 'local' args.push(b.literal(true)); }