Skip to content

Commit cb3ab67

Browse files
committed
feat: support #each without as
1 parent 29d9f94 commit cb3ab67

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- (feat) Svelte 5: support upcoming `<svelte:boundary>`
66
- (feat) Svelte 5: support upcoming `<svelte:html>`
7+
- (feat) Svelte 5: support upcoming `#each` without `as`
78

89
## 3.2.8
910

src/print/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,11 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D
499499
return ['{:else}', printSvelteBlockChildren(path, print, options)];
500500
}
501501
case 'EachBlock': {
502-
const def: Doc[] = [
503-
'{#each ',
504-
printJS(path, print, 'expression'),
505-
' as',
506-
expandNode(node.context, options.originalText),
507-
];
502+
const def: Doc[] = ['{#each ', printJS(path, print, 'expression')];
503+
504+
if (node.context) {
505+
def.push(' as', expandNode(node.context, options.originalText));
506+
}
508507

509508
if (node.index) {
510509
def.push(', ', node.index);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{#each [1, 2, 3]}
2+
<p>hi</p>
3+
{/each}
4+
5+
{#each [1, 2, 3], i}
6+
<p>{i}</p>
7+
{/each}

0 commit comments

Comments
 (0)