File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
packages/svelte/src/compiler/phases/3-transform/client/visitors Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -414,13 +414,20 @@ function setup_select_synchronization(value_binding, context) {
414
414
bound = /** @type {Identifier | MemberExpression } */ ( bound . object ) ;
415
415
}
416
416
417
- // guard against reactively-derived bindings to prevent circular dependencies
417
+ // Skip synchronisation if the bound identifier is *already* updated by a
418
+ // reactive statement (declared directly in `$:` or assigned inside one).
419
+ // In those cases the extra invalidate-helper would re-write its own
420
+ // source signal and create a circular update loop.
418
421
if ( bound . type === 'Identifier' ) {
419
422
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 ;
423
+ if ( binding ) {
424
+ // 1) declared directly inside a `$:`
425
+ if ( binding . kind === 'legacy_reactive' ) return ;
426
+
427
+ // 2) declared elsewhere but *assigned* inside a `$:` block
428
+ for ( const [ , rs ] of context . state . analysis . reactive_statements ) {
429
+ if ( rs . assignments . has ( binding ) ) return ;
430
+ }
424
431
}
425
432
}
426
433
You can’t perform that action at this time.
0 commit comments