File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed
packages/svelte/src/internal/client Expand file tree Collapse file tree 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 {
3232 HEAD_EFFECT ,
3333 MAYBE_DIRTY ,
3434 EFFECT_HAS_DERIVED ,
35- BOUNDARY_EFFECT
35+ BOUNDARY_EFFECT ,
36+ DISCONNECTED
3637} from '../constants.js' ;
3738import { set } from './sources.js' ;
3839import * as e from '../errors.js' ;
@@ -229,7 +230,7 @@ export function inspect_effect(fn) {
229230 * @returns {() => void }
230231 */
231232export function effect_root ( fn ) {
232- const effect = create_effect ( ROOT_EFFECT , fn , true ) ;
233+ const effect = create_effect ( ROOT_EFFECT | DISCONNECTED , fn , true ) ;
233234
234235 return ( ) => {
235236 destroy_effect ( effect ) ;
Original file line number Diff line number Diff line change @@ -738,7 +738,14 @@ export function schedule_effect(signal) {
738738 }
739739 }
740740
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+ }
742749}
743750
744751/**
You can’t perform that action at this time.
0 commit comments