Skip to content

Commit

Permalink
(fix) Don't step out of if block on else if (#874)
Browse files Browse the repository at this point in the history
`else if`s are represented with an if block node inside them, which is correctly handled when entering, but when leaving it would previously incorrectly step out of the if block leading to an internal error.
  • Loading branch information
Liamolucko authored Mar 11, 2021
1 parent 4411fce commit bb40cb8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/svelte2tsx/src/htmlxtojsx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ export function convertHtmlxToJsx(
try {
switch (node.type) {
case 'IfBlock':
ifScope = ifScope.getParent();
if (!node.elseif) {
ifScope = ifScope.getParent();
}
break;
case 'EachBlock':
templateScopeManager.eachLeave(node);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<>{(true) ? <>
{(true) ? <></> : (true) ? <></> : <></> }
</> : <>
{__sveltets_each([], (_) => /*Ωignore_startΩ*/(!(true)) && /*Ωignore_endΩ*/<></>)}
</> }</>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{#if true}
{#if true}{:else if true}{/if}
{:else}
{#each [] as _}{/each}
{/if}

0 comments on commit bb40cb8

Please sign in to comment.