File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
packages/svelte/src/internal/client/reactivity Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -231,14 +231,16 @@ export class Batch {
231231 if ( this . #async_effects. length === 0 && this . #pending === 0 ) {
232232 if ( superseeded_batches . length > 0 ) {
233233 const own = [ ...this . #callbacks. keys ( ) ] . map ( ( c ) => c ( ) ) ;
234- for ( const batch of superseeded_batches ) {
235- // A superseeded batch could have callbacks for e.g. destroying if blocks
236- // that are not part of the current batch because it already happened in the prior one,
237- // and the corresponding block effect therefore returning early because nothing was changed from its
238- // point of view, therefore not adding a callback to the current batch, so we gotta call them here.
234+ // A superseeded batch could have callbacks for e.g. destroying if blocks
235+ // that are not part of the current batch because it already happened in the prior one,
236+ // and the corresponding block effect therefore returning early because nothing was changed from its
237+ // point of view, therefore not adding a callback to the current batch, so we gotta call them here.
238+ // We do it from newest to oldest to ensure the correct callback is applied.
239+ for ( const batch of superseeded_batches . reverse ( ) ) {
239240 for ( const [ effect , cb ] of batch . #callbacks) {
240241 if ( ! own . includes ( effect ( ) ) ) {
241242 cb ( ) ;
243+ own . push ( effect ( ) ) ;
242244 }
243245 }
244246 batch . remove ( ) ;
You can’t perform that action at this time.
0 commit comments