Skip to content

Commit 7c7f2cd

Browse files
committed
fix: makes keyed each blocks consistent between dev and prod
1 parent 4b274dd commit 7c7f2cd

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

.changeset/spotty-rocks-destroy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte": patch
3+
---
4+
5+
fix: makes keyed each blocks consistent between dev and prod

packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,17 +2376,16 @@ export const template_visitors = {
23762376
/** @type {import('estree').BlockStatement} */ (context.visit(node.fallback))
23772377
)
23782378
: b.literal(null);
2379-
const key_function =
2380-
node.key && ((each_type & EACH_ITEM_REACTIVE) !== 0 || context.state.options.dev)
2381-
? b.arrow(
2382-
[node.context.type === 'Identifier' ? node.context : b.id('$$item'), index],
2383-
b.block(
2384-
declarations.concat(
2385-
b.return(/** @type {import('estree').Expression} */ (context.visit(node.key)))
2386-
)
2379+
const key_function = node.key
2380+
? b.arrow(
2381+
[node.context.type === 'Identifier' ? node.context : b.id('$$item'), index],
2382+
b.block(
2383+
declarations.concat(
2384+
b.return(/** @type {import('estree').Expression} */ (context.visit(node.key)))
23872385
)
23882386
)
2389-
: b.literal(null);
2387+
)
2388+
: b.literal(null);
23902389

23912390
if (node.index && each_node_meta.contains_group_binding) {
23922391
// We needed to create a unique identifier for the index above, but we want to use the

0 commit comments

Comments
 (0)