Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Fixes #13768
The bug
In legacy mode Svelte generates extra code for every
<select bind:value={…}>
.That helper reads the bound value and immediately calls
invalidate_inner_signals
, which writes back to the signals it justread so that indirect updates propagate.
When the bound value itself is produced by a reactive statement
(
$:
) this write-back creates a tight loop:details.country
invalidate_inner_signals
doesinternal_set(data, data)
$:
re-runs, re-assignsdetails
runtime throws
effect_update_depth_exceeded
.What this PR does
Stops emitting the helper when it’s not needed.
In
setup_select_synchronization
we now check the bound identifier:If either condition is true the synchronisation helper is omitted,
breaking the cycle. For all other bindings (plain state, props,
store-subs, etc.) the helper is still generated, so existing behaviour should be
unchanged.
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
pnpm test
and lint the project withpnpm lint