fix: makes keyed each blocks consistent between dev and prod

pull/10500/head
Dominic Gannaway 3 years ago
parent 4b274dd00d
commit 7c7f2cd0cb

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: makes keyed each blocks consistent between dev and prod

@ -2376,17 +2376,16 @@ export const template_visitors = {
/** @type {import('estree').BlockStatement} */ (context.visit(node.fallback))
)
: b.literal(null);
const key_function =
node.key && ((each_type & EACH_ITEM_REACTIVE) !== 0 || context.state.options.dev)
? b.arrow(
[node.context.type === 'Identifier' ? node.context : b.id('$$item'), index],
b.block(
declarations.concat(
b.return(/** @type {import('estree').Expression} */ (context.visit(node.key)))
)
const key_function = node.key
? b.arrow(
[node.context.type === 'Identifier' ? node.context : b.id('$$item'), index],
b.block(
declarations.concat(
b.return(/** @type {import('estree').Expression} */ (context.visit(node.key)))
)
)
: b.literal(null);
)
: b.literal(null);
if (node.index && each_node_meta.contains_group_binding) {
// We needed to create a unique identifier for the index above, but we want to use the

Loading…
Cancel
Save