Skip to content

Commit 2c93c25

Browse files
authored
fix: makes keyed each blocks consistent between dev and prod (#10500)
1 parent ba0bdc7 commit 2c93c25

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
@@ -2383,17 +2383,16 @@ export const template_visitors = {
23832383
/** @type {import('estree').BlockStatement} */ (context.visit(node.fallback))
23842384
)
23852385
: b.literal(null);
2386-
const key_function =
2387-
node.key && ((each_type & EACH_ITEM_REACTIVE) !== 0 || context.state.options.dev)
2388-
? b.arrow(
2389-
[node.context.type === 'Identifier' ? node.context : b.id('$$item'), index],
2390-
b.block(
2391-
declarations.concat(
2392-
b.return(/** @type {import('estree').Expression} */ (context.visit(node.key)))
2393-
)
2386+
const key_function = node.key
2387+
? b.arrow(
2388+
[node.context.type === 'Identifier' ? node.context : b.id('$$item'), index],
2389+
b.block(
2390+
declarations.concat(
2391+
b.return(/** @type {import('estree').Expression} */ (context.visit(node.key)))
23942392
)
23952393
)
2396-
: b.literal(null);
2394+
)
2395+
: b.literal(null);
23972396

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

0 commit comments

Comments
 (0)