diff --git a/src/ast.ts b/src/ast.ts index 00805e44..10d203d3 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -125,7 +125,7 @@ export interface SvelteHTMLElement extends BaseSvelteElement { | SvelteProgram | SvelteElement | SvelteIfBlock - | SvelteElseBlock + | SvelteElseBlockAlone | SvelteEachBlock | SvelteAwaitPendingBlock | SvelteAwaitThenBlock @@ -144,7 +144,7 @@ export interface SvelteComponentElement extends BaseSvelteElement { | SvelteProgram | SvelteElement | SvelteIfBlock - | SvelteElseBlock + | SvelteElseBlockAlone | SvelteEachBlock | SvelteAwaitPendingBlock | SvelteAwaitThenBlock @@ -163,7 +163,7 @@ export interface SvelteSpecialElement extends BaseSvelteElement { | SvelteProgram | SvelteElement | SvelteIfBlock - | SvelteElseBlock + | SvelteElseBlockAlone | SvelteEachBlock | SvelteAwaitPendingBlock | SvelteAwaitThenBlock @@ -215,7 +215,7 @@ type Child = | SvelteText | SvelteMustacheTag | SvelteDebugTag - | SvelteIfBlock + | SvelteIfBlockAlone | SvelteEachBlock | SvelteAwaitBlock | SvelteKeyBlock @@ -230,7 +230,7 @@ export interface SvelteText extends BaseNode { | SvelteElement | SvelteStyleElement | SvelteIfBlock - | SvelteElseBlock + | SvelteElseBlockAlone | SvelteEachBlock | SvelteAwaitPendingBlock | SvelteAwaitThenBlock @@ -244,12 +244,17 @@ export interface SvelteLiteral extends BaseNode { parent: SvelteAttribute } +/** Node of mustache tag. e.g. `{...}`, `{@html ...}`. Like JSXExpressionContainer */ +export type SvelteMustacheTag = SvelteMustacheTagText | SvelteMustacheTagRaw interface BaseSvelteMustacheTag extends BaseNode { + type: "SvelteMustacheTag" + kind: "text" | "raw" + expression: ESTree.Expression parent: | SvelteProgram | SvelteElement | SvelteIfBlock - | SvelteElseBlock + | SvelteElseBlockAlone | SvelteEachBlock | SvelteAwaitPendingBlock | SvelteAwaitThenBlock @@ -257,19 +262,33 @@ interface BaseSvelteMustacheTag extends BaseNode { | SvelteKeyBlock | SvelteAttribute } -/** Node of mustache tag. e.g. `{...}`, `{@html ...}`. Like JSXExpressionContainer */ -export interface SvelteMustacheTag extends BaseSvelteMustacheTag { - type: "SvelteMustacheTag" - kind: "text" | "raw" - expression: ESTree.Expression +/** Node of mustache tag. e.g. `{...}``. Like JSXExpressionContainer */ +export interface SvelteMustacheTagText extends BaseSvelteMustacheTag { + kind: "text" +} +/** Node of mustache tag. e.g. `{@html ...}`. Like JSXExpressionContainer */ +export interface SvelteMustacheTagRaw extends BaseSvelteMustacheTag { + kind: "raw" } /** Node of debug mustache tag. e.g. `{@debug}` */ -export interface SvelteDebugTag extends BaseSvelteMustacheTag { +export interface SvelteDebugTag extends BaseNode { type: "SvelteDebugTag" identifiers: ESTree.Identifier[] + parent: + | SvelteProgram + | SvelteElement + | SvelteIfBlock + | SvelteElseBlockAlone + | SvelteEachBlock + | SvelteAwaitPendingBlock + | SvelteAwaitThenBlock + | SvelteAwaitCatchBlock + | SvelteKeyBlock + | SvelteAttribute } /** Node of if block. e.g. `{#if}` */ -export interface SvelteIfBlock extends BaseNode { +export type SvelteIfBlock = SvelteIfBlockAlone | SvelteIfBlockElseIf +interface BaseSvelteIfBlock extends BaseNode { type: "SvelteIfBlock" elseif: boolean expression: ESTree.Expression @@ -286,12 +305,35 @@ export interface SvelteIfBlock extends BaseNode { | SvelteAwaitCatchBlock | SvelteKeyBlock } +/** Node of if block. e.g. `{#if}` */ +export interface SvelteIfBlockAlone extends BaseSvelteIfBlock { + elseif: false + parent: Exclude +} +/** Node of if block. e.g. `{:else #if}` */ +export interface SvelteIfBlockElseIf extends BaseSvelteIfBlock { + elseif: true + parent: SvelteElseBlockElseIf +} + /** Node of else block. e.g. `{:else}` */ -export interface SvelteElseBlock extends BaseNode { +export type SvelteElseBlock = SvelteElseBlockAlone | SvelteElseBlockElseIf +interface BaseSvelteElseBlock extends BaseNode { type: "SvelteElseBlock" - children: Child[] + elseif: boolean + children: (Child | SvelteIfBlockElseIf)[] parent: SvelteIfBlock | SvelteEachBlock } +/** Node of else block. e.g. `{:else}` */ +export interface SvelteElseBlockAlone extends BaseSvelteElseBlock { + elseif: false + children: Child[] +} +/** Node of else block. e.g. `{:else if ...}` */ +export interface SvelteElseBlockElseIf extends BaseSvelteElseBlock { + elseif: true + children: [SvelteIfBlockElseIf] +} /** Node of each block. e.g. `{#each}` */ export interface SvelteEachBlock extends BaseNode { type: "SvelteEachBlock" @@ -300,22 +342,27 @@ export interface SvelteEachBlock extends BaseNode { index: ESTree.Identifier | null key: ESTree.Expression | null children: Child[] - else: SvelteElseBlock | null + else: SvelteElseBlockAlone | null parent: | SvelteProgram | SvelteElement | SvelteIfBlock - | SvelteElseBlock + | SvelteElseBlockAlone | SvelteEachBlock | SvelteAwaitPendingBlock | SvelteAwaitThenBlock | SvelteAwaitCatchBlock | SvelteKeyBlock } -/** Node of await block. e.g. `{#await}` */ -export interface SvelteAwaitBlock extends BaseNode { +/** Node of await block. e.g. `{#await}`, `{#await ... then ... }`, `{#await ... catch ... }` */ +export type SvelteAwaitBlock = + | SvelteAwaitBlockAwaitPending + | SvelteAwaitBlockAwaitThen + | SvelteAwaitBlockAwaitCatch +interface BaseSvelteAwaitBlock extends BaseNode { type: "SvelteAwaitBlock" expression: ESTree.Expression + kind: "await" | "await-then" | "await-catch" pending: SvelteAwaitPendingBlock | null then: SvelteAwaitThenBlock | null catch: SvelteAwaitCatchBlock | null @@ -323,33 +370,88 @@ export interface SvelteAwaitBlock extends BaseNode { | SvelteProgram | SvelteElement | SvelteIfBlock - | SvelteElseBlock + | SvelteElseBlockAlone | SvelteEachBlock | SvelteAwaitPendingBlock | SvelteAwaitThenBlock | SvelteAwaitCatchBlock | SvelteKeyBlock } +/** Node of await block. e.g. `{#await}` */ +export interface SvelteAwaitBlockAwaitPending extends BaseSvelteAwaitBlock { + kind: "await" + pending: SvelteAwaitPendingBlock + then: SvelteAwaitThenBlockAlone | null + catch: SvelteAwaitCatchBlockAlone | null +} +/** Node of await block. e.g. `{#await ... then ... }` */ +export interface SvelteAwaitBlockAwaitThen extends BaseSvelteAwaitBlock { + kind: "await-then" + pending: null + then: SvelteAwaitThenBlockAwaitThen + catch: SvelteAwaitCatchBlockAlone | null +} +/** Node of await block. e.g. `{#await ... catch ... }` */ +export interface SvelteAwaitBlockAwaitCatch extends BaseSvelteAwaitBlock { + kind: "await-catch" + pending: null + then: null + catch: SvelteAwaitCatchBlockAwaitCatch +} + /** Node of await pending block. e.g. `{#await expr} ... {:then}` */ export interface SvelteAwaitPendingBlock extends BaseNode { type: "SvelteAwaitPendingBlock" children: Child[] parent: SvelteAwaitBlock } -/** Node of await then block. e.g. `{:then}` */ -export interface SvelteAwaitThenBlock extends BaseNode { +/** Node of await then block. e.g. `{:then}`, `{#await ... then ...}` */ +export type SvelteAwaitThenBlock = + | SvelteAwaitThenBlockAlone + | SvelteAwaitThenBlockAwaitThen +interface BaseSvelteAwaitThenBlock extends BaseNode { type: "SvelteAwaitThenBlock" + awaitThen: boolean value: ESTree.Pattern | null children: Child[] parent: SvelteAwaitBlock } -/** Node of await catch block. e.g. `{:catch}` */ -export interface SvelteAwaitCatchBlock extends BaseNode { +/** Node of await then block. e.g. `{:then}` */ +export interface SvelteAwaitThenBlockAlone extends BaseSvelteAwaitThenBlock { + awaitThen: false + parent: SvelteAwaitBlockAwaitPending +} +/** Node of await then block. e.g. `{#await ... then ...}` */ +export interface SvelteAwaitThenBlockAwaitThen + extends BaseSvelteAwaitThenBlock { + awaitThen: true + parent: SvelteAwaitBlockAwaitThen +} + +/** Node of await catch block. e.g. `{:catch}`, `{#await ... catch ... }` */ +export type SvelteAwaitCatchBlock = + | SvelteAwaitCatchBlockAlone + | SvelteAwaitCatchBlockAwaitCatch +interface BaseSvelteAwaitCatchBlock extends BaseNode { type: "SvelteAwaitCatchBlock" + awaitCatch: boolean error: ESTree.Pattern | null children: Child[] parent: SvelteAwaitBlock } +/** Node of await catch block. e.g. `{:catch}` */ +export interface SvelteAwaitCatchBlockAlone extends BaseSvelteAwaitCatchBlock { + awaitCatch: false + parent: SvelteAwaitBlockAwaitPending | SvelteAwaitBlockAwaitThen +} +/** Node of await catch block. e.g. `{#await ... catch ... }` */ +export interface SvelteAwaitCatchBlockAwaitCatch + extends BaseSvelteAwaitCatchBlock { + awaitCatch: true + error: ESTree.Pattern | null + children: Child[] + parent: SvelteAwaitBlockAwaitCatch +} /** Node of key block. e.g. `{#key}` */ export interface SvelteKeyBlock extends BaseNode { type: "SvelteKeyBlock" @@ -359,7 +461,7 @@ export interface SvelteKeyBlock extends BaseNode { | SvelteProgram | SvelteElement | SvelteIfBlock - | SvelteElseBlock + | SvelteElseBlockAlone | SvelteEachBlock | SvelteAwaitPendingBlock | SvelteAwaitThenBlock @@ -374,7 +476,7 @@ export interface SvelteHTMLComment extends BaseNode { | SvelteProgram | SvelteElement | SvelteIfBlock - | SvelteElseBlock + | SvelteElseBlockAlone | SvelteEachBlock | SvelteAwaitPendingBlock | SvelteAwaitThenBlock diff --git a/src/parser/converts/block.ts b/src/parser/converts/block.ts index 73ba21fe..fc131b4d 100644 --- a/src/parser/converts/block.ts +++ b/src/parser/converts/block.ts @@ -1,12 +1,18 @@ import type * as SvAST from "../svelte-ast-types" import type { SvelteAwaitBlock, + SvelteAwaitBlockAwaitCatch, + SvelteAwaitBlockAwaitThen, SvelteAwaitCatchBlock, SvelteAwaitPendingBlock, SvelteAwaitThenBlock, SvelteEachBlock, SvelteElseBlock, + SvelteElseBlockAlone, + SvelteElseBlockElseIf, SvelteIfBlock, + SvelteIfBlockAlone, + SvelteIfBlockElseIf, SvelteKeyBlock, } from "../../ast" import type { Context } from "../../context" @@ -37,37 +43,49 @@ function startBlockIndex(code: string, endIndex: number): number { ) } +export function convertIfBlock( + node: SvAST.IfBlock, + parent: SvelteIfBlock["parent"], + ctx: Context, +): SvelteIfBlockAlone +export function convertIfBlock( + node: SvAST.IfBlock, + parent: SvelteIfBlock["parent"], + ctx: Context, + elseif: true, +): SvelteIfBlockElseIf /** Convert for IfBlock */ export function convertIfBlock( node: SvAST.IfBlock, parent: SvelteIfBlock["parent"], ctx: Context, + elseif?: true, ): SvelteIfBlock { // {#if expr} {:else} {/if} // {:else if expr} {/if} - const nodeStart = node.elseif + const nodeStart = elseif ? startBlockIndex(ctx.code, node.start - 1) : node.start const ifBlock: SvelteIfBlock = { type: "SvelteIfBlock", - elseif: Boolean(node.elseif), + elseif: Boolean(elseif), expression: null as any, children: [], else: null, parent, ...ctx.getConvertLocation({ start: nodeStart, end: node.end }), - } + } as SvelteIfBlock ctx.scriptLet.nestIfBlock(node.expression, ifBlock, (es) => { ifBlock.expression = es }) ifBlock.children.push(...convertChildren(node, ifBlock, ctx)) ctx.scriptLet.closeScope() - if (node.elseif) { + if (elseif) { const index = ctx.code.indexOf("if", nodeStart) ctx.addToken("MustacheKeyword", { start: index, end: index + 2 }) } - extractMustacheBlockTokens(ifBlock, ctx, { startOnly: node.elseif }) + extractMustacheBlockTokens(ifBlock, ctx, { startOnly: elseif }) if (!node.else) { return ifBlock @@ -75,39 +93,48 @@ export function convertIfBlock( const elseStart = startBlockIndex(ctx.code, node.else.start - 1) - const elseBlock: SvelteElseBlock = { - type: "SvelteElseBlock", - children: [], - parent: ifBlock, - ...ctx.getConvertLocation({ - start: elseStart, - end: node.else.end, - }), - } - ifBlock.else = elseBlock - - let elseIfBlock: SvelteIfBlock | null = null if (node.else.children.length === 1) { const c = node.else.children[0] if (c.type === "IfBlock" && c.elseif) { - elseIfBlock = convertIfBlock(c, elseBlock, ctx) + const elseBlock: SvelteElseBlockElseIf = { + type: "SvelteElseBlock", + elseif: true, + children: [] as any, + parent: ifBlock, + ...ctx.getConvertLocation({ + start: elseStart, + end: node.else.end, + }), + } + ifBlock.else = elseBlock + + const elseIfBlock = convertIfBlock(c, elseBlock, ctx, true) // adjust loc elseBlock.range[1] = elseIfBlock.range[1] elseBlock.loc.end = { line: elseIfBlock.loc.end.line, column: elseIfBlock.loc.end.column, } + elseBlock.children = [elseIfBlock] + return ifBlock } } - - if (elseIfBlock) { - elseBlock.children.push(elseIfBlock) - } else { - ctx.scriptLet.nestBlock(elseBlock) - elseBlock.children.push(...convertChildren(node.else, elseBlock, ctx)) - ctx.scriptLet.closeScope() - extractMustacheBlockTokens(elseBlock, ctx, { startOnly: true }) + const elseBlock: SvelteElseBlockAlone = { + type: "SvelteElseBlock", + elseif: false, + children: [], + parent: ifBlock, + ...ctx.getConvertLocation({ + start: elseStart, + end: node.else.end, + }), } + ifBlock.else = elseBlock + + ctx.scriptLet.nestBlock(elseBlock) + elseBlock.children.push(...convertChildren(node.else, elseBlock, ctx)) + ctx.scriptLet.closeScope() + extractMustacheBlockTokens(elseBlock, ctx, { startOnly: true }) return ifBlock } @@ -175,8 +202,9 @@ export function convertEachBlock( const elseStart = startBlockIndex(ctx.code, node.else.start - 1) - const elseBlock: SvelteElseBlock = { + const elseBlock: SvelteElseBlockAlone = { type: "SvelteElseBlock", + elseif: false, children: [], parent: eachBlock, ...ctx.getConvertLocation({ @@ -200,15 +228,16 @@ export function convertAwaitBlock( parent: SvelteAwaitBlock["parent"], ctx: Context, ): SvelteAwaitBlock { - const awaitBlock: SvelteAwaitBlock = { + const awaitBlock = { type: "SvelteAwaitBlock", expression: null as any, - pending: null, - then: null, - catch: null, + kind: "await", + pending: null as any, + then: null as any, + catch: null as any, parent, ...ctx.getConvertLocation(node), - } + } as SvelteAwaitBlock ctx.scriptLet.addExpression( node.expression, @@ -237,12 +266,18 @@ export function convertAwaitBlock( ctx.scriptLet.closeScope() } if (!node.then.skip) { + const awaitThen = Boolean(node.pending.skip) + if (awaitThen) { + ;(awaitBlock as SvelteAwaitBlockAwaitThen).kind = "await-then" + } + const thenStart = awaitBlock.pending ? node.then.start : node.start const thenBlock: SvelteAwaitThenBlock = { type: "SvelteAwaitThenBlock", + awaitThen, value: null, children: [], - parent: awaitBlock, + parent: awaitBlock as any, ...ctx.getConvertLocation({ start: thenStart, end: node.then.end, @@ -282,12 +317,17 @@ export function convertAwaitBlock( ctx.scriptLet.closeScope() } if (!node.catch.skip) { + const awaitCatch = Boolean(node.pending.skip && node.then.skip) + if (awaitCatch) { + ;(awaitBlock as SvelteAwaitBlockAwaitCatch).kind = "await-catch" + } const catchStart = awaitBlock.pending || awaitBlock.then ? node.catch.start : node.start - const catchBlock: SvelteAwaitCatchBlock = { + const catchBlock = { type: "SvelteAwaitCatchBlock", + awaitCatch, error: null, children: [], parent: awaitBlock, @@ -295,7 +335,7 @@ export function convertAwaitBlock( start: catchStart, end: node.catch.end, }), - } + } as SvelteAwaitCatchBlock if (node.error) { ctx.scriptLet.nestBlock( diff --git a/src/parser/converts/element.ts b/src/parser/converts/element.ts index 22f1bb64..b68c85ab 100644 --- a/src/parser/converts/element.ts +++ b/src/parser/converts/element.ts @@ -7,10 +7,11 @@ import type { SvelteDebugTag, SvelteEachBlock, SvelteElement, - SvelteElseBlock, + SvelteElseBlockAlone, SvelteHTMLComment, SvelteHTMLElement, SvelteIfBlock, + SvelteIfBlockAlone, SvelteKeyBlock, SvelteMemberExpressionName, SvelteMustacheTag, @@ -50,7 +51,7 @@ export function* convertChildren( | SvelteProgram | SvelteElement | SvelteIfBlock - | SvelteElseBlock + | SvelteElseBlockAlone | SvelteEachBlock | SvelteAwaitPendingBlock | SvelteAwaitThenBlock @@ -62,7 +63,7 @@ export function* convertChildren( | SvelteElement | SvelteMustacheTag | SvelteDebugTag - | SvelteIfBlock + | SvelteIfBlockAlone | SvelteEachBlock | SvelteAwaitBlock | SvelteKeyBlock diff --git a/src/parser/converts/mustache.ts b/src/parser/converts/mustache.ts index 1870830f..7d98f1c8 100644 --- a/src/parser/converts/mustache.ts +++ b/src/parser/converts/mustache.ts @@ -1,4 +1,9 @@ -import type { SvelteDebugTag, SvelteMustacheTag } from "../../ast" +import type { + SvelteDebugTag, + SvelteMustacheTag, + SvelteMustacheTagRaw, + SvelteMustacheTagText, +} from "../../ast" import type { Context } from "../../context" import type * as SvAST from "../svelte-ast-types" /** Convert for MustacheTag */ @@ -6,7 +11,7 @@ export function convertMustacheTag( node: SvAST.MustacheTag, parent: SvelteMustacheTag["parent"], ctx: Context, -): SvelteMustacheTag & { kind: "text" } { +): SvelteMustacheTagText { return convertMustacheTag0(node, "text", parent, ctx) } /** Convert for MustacheTag */ @@ -14,8 +19,13 @@ export function convertRawMustacheTag( node: SvAST.RawMustacheTag, parent: SvelteMustacheTag["parent"], ctx: Context, -): SvelteMustacheTag & { kind: "raw" } { - const mustache = convertMustacheTag0(node, "raw", parent, ctx) +): SvelteMustacheTagRaw { + const mustache: SvelteMustacheTagRaw = convertMustacheTag0( + node, + "raw", + parent, + ctx, + ) const atHtmlStart = ctx.code.indexOf("@html", mustache.range[0]) ctx.addToken("MustacheKeyword", { start: atHtmlStart, @@ -27,7 +37,7 @@ export function convertRawMustacheTag( /** Convert for DebugTag */ export function convertDebugTag( node: SvAST.DebugTag, - parent: SvelteMustacheTag["parent"], + parent: SvelteDebugTag["parent"], ctx: Context, ): SvelteDebugTag { const mustache: SvelteDebugTag = { @@ -50,19 +60,19 @@ export function convertDebugTag( } /** Convert to MustacheTag */ -function convertMustacheTag0( +function convertMustacheTag0( node: SvAST.MustacheTag | SvAST.RawMustacheTag, - kind: K, - parent: SvelteMustacheTag["parent"], + kind: T["kind"], + parent: T["parent"], ctx: Context, -): SvelteMustacheTag & { kind: K } { - const mustache: SvelteMustacheTag & { kind: K } = { +): T { + const mustache = { type: "SvelteMustacheTag", kind, expression: null as any, parent, ...ctx.getConvertLocation(node), - } + } as T ctx.scriptLet.addExpression(node.expression, mustache, null, (es) => { mustache.expression = es }) diff --git a/tests/fixtures/parser/ast/await01-output.json b/tests/fixtures/parser/ast/await01-output.json index 6081b217..431d4e56 100644 --- a/tests/fixtures/parser/ast/await01-output.json +++ b/tests/fixtures/parser/ast/await01-output.json @@ -185,6 +185,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await", "expression": { "type": "Identifier", "name": "expression", @@ -242,6 +243,7 @@ }, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": false, "value": null, "children": [ { @@ -280,6 +282,7 @@ }, "catch": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": false, "error": null, "children": [ { @@ -351,6 +354,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await", "expression": { "type": "Identifier", "name": "expression", @@ -408,6 +412,7 @@ }, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": false, "value": null, "children": [ { @@ -480,6 +485,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await-then", "expression": { "type": "Identifier", "name": "expression", @@ -501,6 +507,7 @@ "pending": null, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": true, "value": { "type": "Identifier", "name": "name", @@ -590,6 +597,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await-catch", "expression": { "type": "Identifier", "name": "expression", @@ -612,6 +620,7 @@ "then": null, "catch": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": true, "error": { "type": "Identifier", "name": "name", diff --git a/tests/fixtures/parser/ast/await01-scope-output.json b/tests/fixtures/parser/ast/await01-scope-output.json index c5a65622..b170929d 100644 --- a/tests/fixtures/parser/ast/await01-scope-output.json +++ b/tests/fixtures/parser/ast/await01-scope-output.json @@ -654,6 +654,7 @@ }, "node": { "type": "SvelteAwaitThenBlock", + "awaitThen": true, "value": { "type": "Identifier", "name": "name", @@ -764,6 +765,7 @@ }, "node": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": true, "error": { "type": "Identifier", "name": "name", diff --git a/tests/fixtures/parser/ast/await02-output.json b/tests/fixtures/parser/ast/await02-output.json index 4da9e063..e353ff9f 100644 --- a/tests/fixtures/parser/ast/await02-output.json +++ b/tests/fixtures/parser/ast/await02-output.json @@ -185,6 +185,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await-catch", "expression": { "type": "Identifier", "name": "expression", @@ -207,6 +208,7 @@ "then": null, "catch": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": true, "error": null, "children": [ { @@ -388,6 +390,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await-then", "expression": { "type": "Identifier", "name": "expression", @@ -409,6 +412,7 @@ "pending": null, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": true, "value": null, "children": [ { @@ -557,6 +561,7 @@ }, "catch": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": false, "error": { "type": "Identifier", "name": "theError", @@ -828,6 +833,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await-then", "expression": { "type": "Identifier", "name": "expression", @@ -849,6 +855,7 @@ "pending": null, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": true, "value": null, "children": [ { diff --git a/tests/fixtures/parser/ast/await02-scope-output.json b/tests/fixtures/parser/ast/await02-scope-output.json index 09d0c26a..6704dac2 100644 --- a/tests/fixtures/parser/ast/await02-scope-output.json +++ b/tests/fixtures/parser/ast/await02-scope-output.json @@ -553,6 +553,7 @@ }, "node": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": false, "error": { "type": "Identifier", "name": "theError", diff --git a/tests/fixtures/parser/ast/await03-output.json b/tests/fixtures/parser/ast/await03-output.json index 17e96db6..9a6f0dbe 100644 --- a/tests/fixtures/parser/ast/await03-output.json +++ b/tests/fixtures/parser/ast/await03-output.json @@ -185,6 +185,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await", "expression": { "type": "Identifier", "name": "expression", @@ -223,6 +224,7 @@ }, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": false, "value": null, "children": [], "range": [ @@ -242,6 +244,7 @@ }, "catch": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": false, "error": null, "children": [], "range": [ @@ -294,6 +297,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await", "expression": { "type": "Identifier", "name": "expression", @@ -332,6 +336,7 @@ }, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": false, "value": null, "children": [], "range": [ @@ -385,6 +390,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await", "expression": { "type": "Identifier", "name": "expression", @@ -424,6 +430,7 @@ "then": null, "catch": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": false, "error": null, "children": [], "range": [ diff --git a/tests/fixtures/parser/ast/docs/template-syntax/05-hash-if/01-output.json b/tests/fixtures/parser/ast/docs/template-syntax/05-hash-if/01-output.json index 13e80bf4..704feab8 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/05-hash-if/01-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/05-hash-if/01-output.json @@ -119,6 +119,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": true, "children": [ { "type": "SvelteIfBlock", @@ -269,6 +270,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteText", diff --git a/tests/fixtures/parser/ast/docs/template-syntax/05-hash-if/03-output.json b/tests/fixtures/parser/ast/docs/template-syntax/05-hash-if/03-output.json index 55808ecc..ce32e03b 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/05-hash-if/03-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/05-hash-if/03-output.json @@ -192,6 +192,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": true, "children": [ { "type": "SvelteIfBlock", @@ -384,6 +385,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/fixtures/parser/ast/docs/template-syntax/06-hash-each/01-output.json b/tests/fixtures/parser/ast/docs/template-syntax/06-hash-each/01-output.json index 1f0f5018..998b7bac 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/06-hash-each/01-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/06-hash-each/01-output.json @@ -507,6 +507,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteText", diff --git a/tests/fixtures/parser/ast/docs/template-syntax/06-hash-each/01-scope-output.json b/tests/fixtures/parser/ast/docs/template-syntax/06-hash-each/01-scope-output.json index 34422ae3..4cf23501 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/06-hash-each/01-scope-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/06-hash-each/01-scope-output.json @@ -1236,6 +1236,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteText", diff --git a/tests/fixtures/parser/ast/docs/template-syntax/06-hash-each/06-output.json b/tests/fixtures/parser/ast/docs/template-syntax/06-hash-each/06-output.json index 00d19dac..887b0675 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/06-hash-each/06-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/06-hash-each/06-output.json @@ -192,6 +192,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/fixtures/parser/ast/docs/template-syntax/06-hash-each/06-scope-output.json b/tests/fixtures/parser/ast/docs/template-syntax/06-hash-each/06-scope-output.json index 93eb1c28..eeed2e9d 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/06-hash-each/06-scope-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/06-hash-each/06-scope-output.json @@ -288,6 +288,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/01-output.json b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/01-output.json index 6f651210..b74abe28 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/01-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/01-output.json @@ -3,6 +3,7 @@ "body": [ { "type": "SvelteAwaitBlock", + "kind": "await", "expression": { "type": "Identifier", "name": "expression", @@ -60,6 +61,7 @@ }, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": false, "value": { "type": "Identifier", "name": "name", @@ -115,6 +117,7 @@ }, "catch": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": false, "error": { "type": "Identifier", "name": "name", @@ -203,6 +206,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await", "expression": { "type": "Identifier", "name": "expression", @@ -260,6 +264,7 @@ }, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": false, "value": { "type": "Identifier", "name": "name", @@ -349,6 +354,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await-then", "expression": { "type": "Identifier", "name": "expression", @@ -370,6 +376,7 @@ "pending": null, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": true, "value": { "type": "Identifier", "name": "name", @@ -459,6 +466,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await-catch", "expression": { "type": "Identifier", "name": "expression", @@ -481,6 +489,7 @@ "then": null, "catch": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": true, "error": { "type": "Identifier", "name": "name", diff --git a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/01-scope-output.json b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/01-scope-output.json index 2687b31b..af9742f9 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/01-scope-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/01-scope-output.json @@ -175,6 +175,7 @@ }, "node": { "type": "SvelteAwaitThenBlock", + "awaitThen": false, "value": { "type": "Identifier", "name": "name", @@ -285,6 +286,7 @@ }, "node": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": false, "error": { "type": "Identifier", "name": "name", @@ -402,6 +404,7 @@ }, "node": { "type": "SvelteAwaitThenBlock", + "awaitThen": false, "value": { "type": "Identifier", "name": "name", @@ -512,6 +515,7 @@ }, "node": { "type": "SvelteAwaitThenBlock", + "awaitThen": true, "value": { "type": "Identifier", "name": "name", @@ -622,6 +626,7 @@ }, "node": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": true, "error": { "type": "Identifier", "name": "name", diff --git a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/02-output.json b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/02-output.json index 4c0f46a5..8fd829fb 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/02-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/02-output.json @@ -3,6 +3,7 @@ "body": [ { "type": "SvelteAwaitBlock", + "kind": "await", "expression": { "type": "Identifier", "name": "promise", @@ -206,6 +207,7 @@ }, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": false, "value": { "type": "Identifier", "name": "value", @@ -443,6 +445,7 @@ }, "catch": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": false, "error": { "type": "Identifier", "name": "error", diff --git a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/02-scope-output.json b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/02-scope-output.json index f5eaac1e..75a0e1ef 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/02-scope-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/02-scope-output.json @@ -106,6 +106,7 @@ }, "node": { "type": "SvelteAwaitThenBlock", + "awaitThen": false, "value": { "type": "Identifier", "name": "value", @@ -480,6 +481,7 @@ }, "node": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": false, "error": { "type": "Identifier", "name": "error", diff --git a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/03-output.json b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/03-output.json index ab06b9a6..3158ed34 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/03-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/03-output.json @@ -3,6 +3,7 @@ "body": [ { "type": "SvelteAwaitBlock", + "kind": "await", "expression": { "type": "Identifier", "name": "promise", @@ -206,6 +207,7 @@ }, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": false, "value": { "type": "Identifier", "name": "value", diff --git a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/03-scope-output.json b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/03-scope-output.json index 02b530b2..737039cd 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/03-scope-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/03-scope-output.json @@ -106,6 +106,7 @@ }, "node": { "type": "SvelteAwaitThenBlock", + "awaitThen": false, "value": { "type": "Identifier", "name": "value", diff --git a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/04-output.json b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/04-output.json index 09055b09..b803e582 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/04-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/04-output.json @@ -3,6 +3,7 @@ "body": [ { "type": "SvelteAwaitBlock", + "kind": "await-then", "expression": { "type": "Identifier", "name": "promise", @@ -24,6 +25,7 @@ "pending": null, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": true, "value": { "type": "Identifier", "name": "value", diff --git a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/04-scope-output.json b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/04-scope-output.json index 2aa01948..bae39a01 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/04-scope-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/04-scope-output.json @@ -99,6 +99,7 @@ }, "node": { "type": "SvelteAwaitThenBlock", + "awaitThen": true, "value": { "type": "Identifier", "name": "value", diff --git a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/05-output.json b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/05-output.json index c28380e4..a8d49c62 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/05-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/05-output.json @@ -3,6 +3,7 @@ "body": [ { "type": "SvelteAwaitBlock", + "kind": "await-catch", "expression": { "type": "Identifier", "name": "promise", @@ -25,6 +26,7 @@ "then": null, "catch": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": true, "error": { "type": "Identifier", "name": "error", diff --git a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/05-scope-output.json b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/05-scope-output.json index 2aa623d5..494496fd 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/05-scope-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/07-hash-await/05-scope-output.json @@ -99,6 +99,7 @@ }, "node": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": true, "error": { "type": "Identifier", "name": "error", diff --git a/tests/fixtures/parser/ast/docs/template-syntax/14-svelte-self/01-output.json b/tests/fixtures/parser/ast/docs/template-syntax/14-svelte-self/01-output.json index 581ef1dc..7b3d3982 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/14-svelte-self/01-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/14-svelte-self/01-output.json @@ -544,6 +544,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/fixtures/parser/ast/if-block01-output.json b/tests/fixtures/parser/ast/if-block01-output.json index 359c6b8e..964559ca 100644 --- a/tests/fixtures/parser/ast/if-block01-output.json +++ b/tests/fixtures/parser/ast/if-block01-output.json @@ -25,6 +25,7 @@ "children": [], "else": { "type": "SvelteElseBlock", + "elseif": true, "children": [ { "type": "SvelteIfBlock", @@ -50,6 +51,7 @@ "children": [], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [], "range": [ 37, diff --git a/tests/fixtures/parser/ast/ts-promise01-output.json b/tests/fixtures/parser/ast/ts-promise01-output.json index 19d235a0..a25a1c38 100644 --- a/tests/fixtures/parser/ast/ts-promise01-output.json +++ b/tests/fixtures/parser/ast/ts-promise01-output.json @@ -559,6 +559,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await", "expression": { "type": "Identifier", "name": "promise", @@ -726,6 +727,7 @@ }, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": false, "value": { "type": "Identifier", "name": "number", @@ -964,6 +966,7 @@ }, "catch": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": false, "error": { "type": "Identifier", "name": "error", diff --git a/tests/fixtures/parser/ast/ts-promise01-scope-output.json b/tests/fixtures/parser/ast/ts-promise01-scope-output.json index b0b262a6..0b8baabe 100644 --- a/tests/fixtures/parser/ast/ts-promise01-scope-output.json +++ b/tests/fixtures/parser/ast/ts-promise01-scope-output.json @@ -11072,6 +11072,7 @@ }, "node": { "type": "SvelteAwaitThenBlock", + "awaitThen": false, "value": { "type": "Identifier", "name": "number", @@ -11940,6 +11941,7 @@ }, "node": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": false, "error": { "type": "Identifier", "name": "error", diff --git a/tests/fixtures/parser/ast/tutorial/await-blocks-output.json b/tests/fixtures/parser/ast/tutorial/await-blocks-output.json index d24b0ebb..554500be 100644 --- a/tests/fixtures/parser/ast/tutorial/await-blocks-output.json +++ b/tests/fixtures/parser/ast/tutorial/await-blocks-output.json @@ -1126,6 +1126,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await", "expression": { "type": "Identifier", "name": "promise", @@ -1293,6 +1294,7 @@ }, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": false, "value": { "type": "Identifier", "name": "number", @@ -1494,6 +1496,7 @@ }, "catch": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": false, "error": { "type": "Identifier", "name": "error", @@ -1804,6 +1807,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await-then", "expression": { "type": "Identifier", "name": "promise", @@ -1825,6 +1829,7 @@ "pending": null, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": true, "value": { "type": "Identifier", "name": "value", @@ -2060,6 +2065,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await-catch", "expression": { "type": "Identifier", "name": "promise", @@ -2082,6 +2088,7 @@ "then": null, "catch": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": true, "error": { "type": "Identifier", "name": "error", @@ -2392,6 +2399,7 @@ }, { "type": "SvelteAwaitBlock", + "kind": "await-then", "expression": { "type": "Identifier", "name": "promise", @@ -2413,6 +2421,7 @@ "pending": null, "then": { "type": "SvelteAwaitThenBlock", + "awaitThen": true, "value": { "type": "Identifier", "name": "value", @@ -2614,6 +2623,7 @@ }, "catch": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": false, "error": { "type": "Identifier", "name": "error", diff --git a/tests/fixtures/parser/ast/tutorial/await-blocks-scope-output.json b/tests/fixtures/parser/ast/tutorial/await-blocks-scope-output.json index ae990d70..f49f0151 100644 --- a/tests/fixtures/parser/ast/tutorial/await-blocks-scope-output.json +++ b/tests/fixtures/parser/ast/tutorial/await-blocks-scope-output.json @@ -2901,6 +2901,7 @@ }, "node": { "type": "SvelteAwaitThenBlock", + "awaitThen": false, "value": { "type": "Identifier", "name": "number", @@ -3239,6 +3240,7 @@ }, "node": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": false, "error": { "type": "Identifier", "name": "error", @@ -3653,6 +3655,7 @@ }, "node": { "type": "SvelteAwaitThenBlock", + "awaitThen": true, "value": { "type": "Identifier", "name": "value", @@ -3991,6 +3994,7 @@ }, "node": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": true, "error": { "type": "Identifier", "name": "error", @@ -4405,6 +4409,7 @@ }, "node": { "type": "SvelteAwaitThenBlock", + "awaitThen": true, "value": { "type": "Identifier", "name": "value", @@ -4743,6 +4748,7 @@ }, "node": { "type": "SvelteAwaitCatchBlock", + "awaitCatch": false, "error": { "type": "Identifier", "name": "error", diff --git a/tests/fixtures/parser/ast/tutorial/checkbox-inputs-output.json b/tests/fixtures/parser/ast/tutorial/checkbox-inputs-output.json index 2e4be899..b288f5eb 100644 --- a/tests/fixtures/parser/ast/tutorial/checkbox-inputs-output.json +++ b/tests/fixtures/parser/ast/tutorial/checkbox-inputs-output.json @@ -597,6 +597,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/fixtures/parser/ast/tutorial/else-blocks-output.json b/tests/fixtures/parser/ast/tutorial/else-blocks-output.json index 48217b49..e101c18b 100644 --- a/tests/fixtures/parser/ast/tutorial/else-blocks-output.json +++ b/tests/fixtures/parser/ast/tutorial/else-blocks-output.json @@ -673,6 +673,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/fixtures/parser/ast/tutorial/else-if-blocks01-output.json b/tests/fixtures/parser/ast/tutorial/else-if-blocks01-output.json index 2d7476fe..7e00162e 100644 --- a/tests/fixtures/parser/ast/tutorial/else-if-blocks01-output.json +++ b/tests/fixtures/parser/ast/tutorial/else-if-blocks01-output.json @@ -356,6 +356,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteIfBlock", @@ -547,6 +548,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/fixtures/parser/ast/tutorial/else-if-blocks02-output.json b/tests/fixtures/parser/ast/tutorial/else-if-blocks02-output.json index e275e82f..5883c352 100644 --- a/tests/fixtures/parser/ast/tutorial/else-if-blocks02-output.json +++ b/tests/fixtures/parser/ast/tutorial/else-if-blocks02-output.json @@ -356,6 +356,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": true, "children": [ { "type": "SvelteIfBlock", @@ -547,6 +548,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/fixtures/parser/ast/tutorial/group-inputs-output.json b/tests/fixtures/parser/ast/tutorial/group-inputs-output.json index 636cf541..c4633a76 100644 --- a/tests/fixtures/parser/ast/tutorial/group-inputs-output.json +++ b/tests/fixtures/parser/ast/tutorial/group-inputs-output.json @@ -3169,6 +3169,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": true, "children": [ { "type": "SvelteIfBlock", @@ -3360,6 +3361,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/fixtures/parser/ast/tutorial/multiple-select-bindings-output.json b/tests/fixtures/parser/ast/tutorial/multiple-select-bindings-output.json index 18998e88..81617961 100644 --- a/tests/fixtures/parser/ast/tutorial/multiple-select-bindings-output.json +++ b/tests/fixtures/parser/ast/tutorial/multiple-select-bindings-output.json @@ -3186,6 +3186,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": true, "children": [ { "type": "SvelteIfBlock", @@ -3377,6 +3378,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/fixtures/parser/ast/tutorial/onmount-output.json b/tests/fixtures/parser/ast/tutorial/onmount-output.json index 9268131c..2a802b95 100644 --- a/tests/fixtures/parser/ast/tutorial/onmount-output.json +++ b/tests/fixtures/parser/ast/tutorial/onmount-output.json @@ -1582,6 +1582,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteHTMLComment", diff --git a/tests/fixtures/parser/ast/tutorial/onmount-scope-output.json b/tests/fixtures/parser/ast/tutorial/onmount-scope-output.json index 2b2e8a7d..f5fc6fca 100644 --- a/tests/fixtures/parser/ast/tutorial/onmount-scope-output.json +++ b/tests/fixtures/parser/ast/tutorial/onmount-scope-output.json @@ -1632,6 +1632,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteHTMLComment", diff --git a/tests/fixtures/parser/ast/tutorial/slot-props01-output.json b/tests/fixtures/parser/ast/tutorial/slot-props01-output.json index 01a651ab..377eddee 100644 --- a/tests/fixtures/parser/ast/tutorial/slot-props01-output.json +++ b/tests/fixtures/parser/ast/tutorial/slot-props01-output.json @@ -655,6 +655,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/fixtures/parser/ast/tutorial/slot-props01-scope-output.json b/tests/fixtures/parser/ast/tutorial/slot-props01-scope-output.json index 87bc4dce..accf2237 100644 --- a/tests/fixtures/parser/ast/tutorial/slot-props01-scope-output.json +++ b/tests/fixtures/parser/ast/tutorial/slot-props01-scope-output.json @@ -619,6 +619,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/fixtures/parser/ast/tutorial/slot-props03-output.json b/tests/fixtures/parser/ast/tutorial/slot-props03-output.json index f6ba5ed1..fcc78ca4 100644 --- a/tests/fixtures/parser/ast/tutorial/slot-props03-output.json +++ b/tests/fixtures/parser/ast/tutorial/slot-props03-output.json @@ -655,6 +655,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/fixtures/parser/ast/tutorial/slot-props03-scope-output.json b/tests/fixtures/parser/ast/tutorial/slot-props03-scope-output.json index b2e9c948..b1e9357a 100644 --- a/tests/fixtures/parser/ast/tutorial/slot-props03-scope-output.json +++ b/tests/fixtures/parser/ast/tutorial/slot-props03-scope-output.json @@ -619,6 +619,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/fixtures/parser/ast/tutorial/svelte-self03-output.json b/tests/fixtures/parser/ast/tutorial/svelte-self03-output.json index a65c217e..d8870113 100644 --- a/tests/fixtures/parser/ast/tutorial/svelte-self03-output.json +++ b/tests/fixtures/parser/ast/tutorial/svelte-self03-output.json @@ -1311,6 +1311,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/fixtures/parser/ast/tutorial/svelte-self03-scope-output.json b/tests/fixtures/parser/ast/tutorial/svelte-self03-scope-output.json index f86ebd60..c70a38e1 100644 --- a/tests/fixtures/parser/ast/tutorial/svelte-self03-scope-output.json +++ b/tests/fixtures/parser/ast/tutorial/svelte-self03-scope-output.json @@ -1818,6 +1818,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/fixtures/parser/ast/tutorial/svelte-window-output.json b/tests/fixtures/parser/ast/tutorial/svelte-window-output.json index 6a8c123e..bf736c37 100644 --- a/tests/fixtures/parser/ast/tutorial/svelte-window-output.json +++ b/tests/fixtures/parser/ast/tutorial/svelte-window-output.json @@ -1224,6 +1224,7 @@ ], "else": { "type": "SvelteElseBlock", + "elseif": false, "children": [ { "type": "SvelteElement", diff --git a/tests/src/parser/test-utils.ts b/tests/src/parser/test-utils.ts index ce2ffa06..1ba58208 100644 --- a/tests/src/parser/test-utils.ts +++ b/tests/src/parser/test-utils.ts @@ -187,9 +187,9 @@ const nodeToKeys: SvelteKeysType = { Program: ["body", "sourceType", "comments", "tokens"], SvelteAttribute: ["key", "boolean", "value"], SvelteAwaitBlock: ["expression", "pending", "then", "catch"], - SvelteAwaitCatchBlock: ["error", "children"], + SvelteAwaitCatchBlock: ["awaitCatch", "error", "children"], SvelteAwaitPendingBlock: ["children"], - SvelteAwaitThenBlock: ["value", "children"], + SvelteAwaitThenBlock: ["awaitThen", "value", "children"], SvelteDebugTag: ["identifiers"], SvelteDirective: ["key", "intro", "outro", "expression"], SvelteDirectiveKey: ["name", "modifiers"], @@ -202,7 +202,7 @@ const nodeToKeys: SvelteKeysType = { "else", ], SvelteElement: ["kind", "name", "startTag", "children", "endTag"], - SvelteElseBlock: ["children"], + SvelteElseBlock: ["elseif", "children"], SvelteEndTag: [], SvelteHTMLComment: ["value"], SvelteIfBlock: ["elseif", "expression", "children", "else"],