Skip to content

Commit 02f3f42

Browse files
authored
fix: apply keyed validation only for keyed each (#9641)
1 parent 94afdc8 commit 02f3f42

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.changeset/chilled-pumas-invite.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: apply keyed validation only for keyed each

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2279,19 +2279,19 @@ export const template_visitors = {
22792279
)
22802280
: b.literal(null);
22812281

2282-
if (context.state.options.dev && key_function.type !== 'Literal') {
2283-
context.state.init.push(
2284-
b.stmt(b.call('$.validate_each_keys', b.thunk(collection), key_function))
2285-
);
2286-
}
2287-
22882282
if (node.index && each_node_meta.contains_group_binding) {
22892283
// We needed to create a unique identifier for the index above, but we want to use the
22902284
// original index name in the template, therefore create another binding
22912285
declarations.push(b.let(node.index, index));
22922286
}
22932287

22942288
if ((each_type & EACH_KEYED) !== 0) {
2289+
if (context.state.options.dev && key_function.type !== 'Literal') {
2290+
context.state.init.push(
2291+
b.stmt(b.call('$.validate_each_keys', b.thunk(collection), key_function))
2292+
);
2293+
}
2294+
22952295
context.state.after_update.push(
22962296
b.stmt(
22972297
b.call(

0 commit comments

Comments
 (0)