Skip to content

Commit 5c70fa5

Browse files
committed
Improve compiler output on legacy components to prevent infinite loops from <select> bind:value on $: derived variables
1 parent 4f5c762 commit 5c70fa5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,16 @@ function setup_select_synchronization(value_binding, context) {
414414
bound = /** @type {Identifier | MemberExpression} */ (bound.object);
415415
}
416416

417+
// guard against reactively-derived bindings to prevent circular dependencies
418+
if (bound.type === 'Identifier') {
419+
const binding = context.state.scope.get(bound.name);
420+
if (binding && binding.kind === 'legacy_reactive') {
421+
// skip synchronization for reactive-derived bindings,
422+
// the reactive statement already handles updates properly
423+
return;
424+
}
425+
}
426+
417427
/** @type {string[]} */
418428
const names = [];
419429

0 commit comments

Comments
 (0)