Skip to content

Commit 040d646

Browse files
committed
refactor: Update vdom.Helper.updateBatch to Map-based Payload (#8835)
- Changed updateBatch signature to accept { updates: { id: payload } } - Updated VdomLifecycle.executeVdomUpdate to construct updates map - Verified tests pass
1 parent 690cb06 commit 040d646

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

src/mixin/VdomLifecycle.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class VdomLifecycle extends Base {
206206

207207
try {
208208
const
209-
batch = [],
209+
updates = {},
210210
processed = new Set(); // Prevent duplicates and cycles
211211

212212
const collectPayloads = (componentId) => {
@@ -226,7 +226,7 @@ class VdomLifecycle extends Base {
226226
// Generate payload for this component (Pruned Disjoint Tree, Depth 1)
227227
// We pass null as mergedChildIds to force TreeBuilder to prune ALL children (placeholderize).
228228
// This ensures the parent's payload is strictly disjoint from its children.
229-
batch.push(component.getVdomUpdatePayload(null, 1));
229+
updates[componentId] = component.getVdomUpdatePayload(null, 1);
230230

231231
// Recursively collect merged children
232232
if (mergedChildIds) {
@@ -237,7 +237,7 @@ class VdomLifecycle extends Base {
237237
// Start collection from the root of the update (me)
238238
collectPayloads(me.id);
239239

240-
const response = await Promise.resolve(Neo.vdom.Helper.updateBatch(batch));
240+
const response = await Promise.resolve(Neo.vdom.Helper.updateBatch({updates}));
241241

242242
// Component could be destroyed while the update is running
243243
if (me.id) {
@@ -249,7 +249,7 @@ class VdomLifecycle extends Base {
249249
// Distribute results back to ALL components in the batch
250250
response.results.forEach((result, index) => {
251251
const
252-
payload = batch[index],
252+
payload = Object.values(updates)[index],
253253
componentId = payload.vnode?.id || payload.vdom?.id,
254254
component = Neo.getComponent(componentId);
255255

src/vdom/Helper.mjs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -782,17 +782,18 @@ class Helper extends Base {
782782
}
783783

784784
/**
785-
* Processes an array of updates sequentially and aggregates the results.
786-
* @param {Object[]} updates An array of update config objects (same format as update() accepts)
785+
* Processes a map of updates sequentially and aggregates the results.
786+
* @param {Object} data
787+
* @param {Object} data.updates A map of update config objects: {componentId: updateOpts}
787788
* @returns {Object} { deltas: Object[], results: Object[] }
788789
*/
789-
updateBatch(updates) {
790-
let me = this,
791-
allDeltas = [],
792-
results = [],
790+
updateBatch(data) {
791+
let me = this,
792+
allDeltas = [],
793+
results = [],
793794
result;
794795

795-
updates.forEach(updateOpts => {
796+
Object.values(data.updates).forEach(updateOpts => {
796797
result = me.update(updateOpts);
797798
allDeltas.push(...result.deltas);
798799
results.push({vnode: result.vnode});

0 commit comments

Comments
 (0)