From e95b77cf81264f5506c974b4119d4996bec0850c Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 2 Apr 2026 22:32:44 -0400 Subject: [PATCH] WIP --- .../svelte/src/internal/client/reactivity/batch.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/svelte/src/internal/client/reactivity/batch.js b/packages/svelte/src/internal/client/reactivity/batch.js index a9d9bf27cd..87a8057e65 100644 --- a/packages/svelte/src/internal/client/reactivity/batch.js +++ b/packages/svelte/src/internal/client/reactivity/batch.js @@ -122,6 +122,12 @@ export class Batch { */ previous = new Map(); + /** + * The combination of this batch's `current` and other batches' `previous` values + * @type {Map | null} + */ + values = null; + /** * When the batch is committed (and the DOM is updated), we need to remove old branches * and append new ones by calling the functions added inside (if/each/key/etc) blocks @@ -491,6 +497,7 @@ export class Batch { deactivate() { current_batch = null; + active_batch = null; batch_values = null; } @@ -736,7 +743,6 @@ export class Batch { apply() { if (!async_mode_flag) { // TODO previously we bailed here if there was only one (non-fork) batch... maybe we can reinstate that - batch_values = null; return; } @@ -744,7 +750,8 @@ export class Batch { // if there are multiple batches, we are 'time travelling' — // we need to override values with the ones in this batch... - batch_values = new Map(this.current); + this.values = new Map(this.current); + batch_values = this.values; // ...and undo changes belonging to other batches unless they block this one for (const batch of batches) {