fix: correctly validate nested if block tags (#13218)

Fixes #13210
pull/13223/head
Simon H 1 week ago committed by GitHub
parent 865ec18cb7
commit 804b714096
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -12,15 +12,7 @@ export function IfBlock(node, context) {
validate_block_not_empty(node.alternate, context);
if (context.state.analysis.runes) {
const parent = context.path.at(-1);
const expected =
context.path.at(-2)?.type === 'IfBlock' &&
parent?.type === 'Fragment' &&
parent.nodes.length === 1
? ':'
: '#';
validate_opening_tag(node, context.state, expected);
validate_opening_tag(node, context.state, node.elseif ? ':' : '#');
}
mark_subtree_dynamic(context.path);

@ -3,11 +3,11 @@
"code": "block_unexpected_character",
"message": "Expected a `#` character immediately following the opening bracket",
"start": {
"line": 5,
"line": 10,
"column": 1
},
"end": {
"line": 5,
"line": 10,
"column": 6
}
}

@ -1,5 +1,10 @@
<svelte:options runes={true} />
<!-- ok -->
{#if true}{#if true}{/if}{/if}
{#if foo}{:else if bar}{/if}
{#if foo}{:else}{/if}
<!-- prettier-ignore -->
<div>
{ #if true}

Loading…
Cancel
Save