Skip to content

Commit

Permalink
feat: support #each without as
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed Nov 21, 2024
1 parent 29d9f94 commit cb3ab67
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

- (feat) Svelte 5: support upcoming `<svelte:boundary>`
- (feat) Svelte 5: support upcoming `<svelte:html>`
- (feat) Svelte 5: support upcoming `#each` without `as`

## 3.2.8

11 changes: 5 additions & 6 deletions src/print/index.ts
Original file line number Diff line number Diff line change
@@ -499,12 +499,11 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D
return ['{:else}', printSvelteBlockChildren(path, print, options)];
}
case 'EachBlock': {
const def: Doc[] = [
'{#each ',
printJS(path, print, 'expression'),
' as',
expandNode(node.context, options.originalText),
];
const def: Doc[] = ['{#each ', printJS(path, print, 'expression')];

if (node.context) {
def.push(' as', expandNode(node.context, options.originalText));
}

if (node.index) {
def.push(', ', node.index);
7 changes: 7 additions & 0 deletions test/printer/samples/each-block-without-as.html.skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{#each [1, 2, 3]}
<p>hi</p>
{/each}

{#each [1, 2, 3], i}
<p>{i}</p>
{/each}

0 comments on commit cb3ab67

Please sign in to comment.