File tree 3 files changed +16
-3
lines changed
packages/svelte/src/internal/client
3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' svelte ' : patch
3
+ ---
4
+
5
+ fix: ensure component root effect updates occur first
Original file line number Diff line number Diff line change @@ -32,7 +32,8 @@ import {
32
32
HEAD_EFFECT ,
33
33
MAYBE_DIRTY ,
34
34
EFFECT_HAS_DERIVED ,
35
- BOUNDARY_EFFECT
35
+ BOUNDARY_EFFECT ,
36
+ DISCONNECTED
36
37
} from '../constants.js' ;
37
38
import { set } from './sources.js' ;
38
39
import * as e from '../errors.js' ;
@@ -229,7 +230,7 @@ export function inspect_effect(fn) {
229
230
* @returns {() => void }
230
231
*/
231
232
export function effect_root ( fn ) {
232
- const effect = create_effect ( ROOT_EFFECT , fn , true ) ;
233
+ const effect = create_effect ( ROOT_EFFECT | DISCONNECTED , fn , true ) ;
233
234
234
235
return ( ) => {
235
236
destroy_effect ( effect ) ;
Original file line number Diff line number Diff line change @@ -738,7 +738,14 @@ export function schedule_effect(signal) {
738
738
}
739
739
}
740
740
741
- queued_root_effects . push ( effect ) ;
741
+ // Schedule the root effect for component trees first so any updates
742
+ // that affect the component tree occur first. Root effects that are
743
+ // not for component trees (i.e. $effect.root) will be marked as disconnected
744
+ if ( ( effect . f & DISCONNECTED ) === 0 ) {
745
+ queued_root_effects . unshift ( effect ) ;
746
+ } else {
747
+ queued_root_effects . push ( effect ) ;
748
+ }
742
749
}
743
750
744
751
/**
You can’t perform that action at this time.
0 commit comments