@farm.js/react 0.1.0-beta.16 → 0.1.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2326,17 +2326,15 @@ function applyPreparedKeyedRowBindingUpdates(props, instance, updates) {
|
|
|
2326
2326
|
}
|
|
2327
2327
|
}
|
|
2328
2328
|
function prepareKeyedRowBindingSetUpdates(props, instances, rows) {
|
|
2329
|
-
const preparedInstances = [];
|
|
2330
2329
|
const preparedUpdates = [];
|
|
2331
2330
|
for (let index = 0; index < rows.items.length; index += 1) {
|
|
2332
2331
|
const instance = instances.get(rows.keys[index]);
|
|
2333
2332
|
if (!instance) return void 0;
|
|
2334
2333
|
const updates = prepareKeyedRowBindingUpdates(props, instance, rows.items[index], index);
|
|
2335
2334
|
if (!updates) return void 0;
|
|
2336
|
-
preparedInstances.push(instance);
|
|
2337
2335
|
preparedUpdates.push(updates);
|
|
2338
2336
|
}
|
|
2339
|
-
return
|
|
2337
|
+
return preparedUpdates;
|
|
2340
2338
|
}
|
|
2341
2339
|
function keyedRowConditionalSnapshot(conditional, item, index) {
|
|
2342
2340
|
const test = conditional.test(item, index);
|
|
@@ -6387,7 +6385,7 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6387
6385
|
const conditionalChanges = [];
|
|
6388
6386
|
for (index = 0; index < rows.items.length; index += 1) {
|
|
6389
6387
|
const key = rows.keys[index];
|
|
6390
|
-
const existing =
|
|
6388
|
+
const existing = this.instances.get(key);
|
|
6391
6389
|
if (!existing) return false;
|
|
6392
6390
|
if (this.currentProps.hostBlocks) {
|
|
6393
6391
|
const descriptor = this.currentProps.create(rows.items[index], index);
|
|
@@ -6396,7 +6394,7 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6396
6394
|
return true;
|
|
6397
6395
|
}
|
|
6398
6396
|
}
|
|
6399
|
-
const bindingUpdates = preparedBindings?.[
|
|
6397
|
+
const bindingUpdates = preparedBindings?.[index];
|
|
6400
6398
|
if (bindingUpdates) {
|
|
6401
6399
|
applyPreparedKeyedRowBindingUpdates(this.currentProps, existing, bindingUpdates);
|
|
6402
6400
|
} else {
|
|
@@ -6425,20 +6423,22 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6425
6423
|
this.notifyConditionalChanges(conditionalChanges, afterCommit);
|
|
6426
6424
|
return true;
|
|
6427
6425
|
}
|
|
6428
|
-
|
|
6429
|
-
if (this.hasReactOwnedRows() || rows.keys.length
|
|
6430
|
-
const
|
|
6431
|
-
let
|
|
6432
|
-
|
|
6433
|
-
|
|
6426
|
+
reconcileRemovals(rows, afterCommit, dirtyState) {
|
|
6427
|
+
if (this.hasReactOwnedRows() || rows.keys.length >= this.instances.size) return false;
|
|
6428
|
+
const removed = [];
|
|
6429
|
+
let nextIndex = 0;
|
|
6430
|
+
for (const [key, instance] of this.instances) {
|
|
6431
|
+
if (key === rows.keys[nextIndex]) nextIndex += 1;
|
|
6432
|
+
else removed.push(instance);
|
|
6434
6433
|
}
|
|
6435
|
-
|
|
6436
|
-
|
|
6434
|
+
if (nextIndex !== rows.keys.length) return false;
|
|
6435
|
+
const shouldPrepareBindings = this.currentProps.bindings.length > 0 && !this.currentProps.hostBlocks;
|
|
6436
|
+
if (shouldPrepareBindings && rows.items.length === 1 && this.currentProps.bindings.some(
|
|
6437
|
+
(binding) => !findCompilerHostTarget(this.instances.get(rows.keys[0]).element, binding.path)
|
|
6438
|
+
)) {
|
|
6439
|
+
this.activateFallback(afterCommit);
|
|
6440
|
+
return true;
|
|
6437
6441
|
}
|
|
6438
|
-
const removedKey = previousKeys[removedIndex];
|
|
6439
|
-
const removed = this.instances.get(removedKey);
|
|
6440
|
-
if (!removed) return false;
|
|
6441
|
-
const shouldPrepareBindings = rows.items.length > 1 && this.currentProps.bindings.length > 0 && !this.currentProps.hostBlocks;
|
|
6442
6442
|
const preparedBindings = shouldPrepareBindings ? prepareKeyedRowBindingSetUpdates(this.currentProps, this.instances, rows) : void 0;
|
|
6443
6443
|
if (shouldPrepareBindings && !preparedBindings) {
|
|
6444
6444
|
this.activateFallback(afterCommit);
|
|
@@ -6447,7 +6447,7 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6447
6447
|
const conditionalChanges = [];
|
|
6448
6448
|
for (let index = 0; index < rows.items.length; index += 1) {
|
|
6449
6449
|
const key = rows.keys[index];
|
|
6450
|
-
const existing =
|
|
6450
|
+
const existing = this.instances.get(key);
|
|
6451
6451
|
if (!existing) return false;
|
|
6452
6452
|
if (this.currentProps.hostBlocks) {
|
|
6453
6453
|
const descriptor = this.currentProps.create(rows.items[index], index);
|
|
@@ -6456,7 +6456,7 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6456
6456
|
return true;
|
|
6457
6457
|
}
|
|
6458
6458
|
}
|
|
6459
|
-
const bindingUpdates = preparedBindings?.[
|
|
6459
|
+
const bindingUpdates = preparedBindings?.[index];
|
|
6460
6460
|
if (bindingUpdates) {
|
|
6461
6461
|
applyPreparedKeyedRowBindingUpdates(this.currentProps, existing, bindingUpdates);
|
|
6462
6462
|
} else {
|
|
@@ -6481,11 +6481,13 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6481
6481
|
existing.item = rows.items[index];
|
|
6482
6482
|
existing.index = index;
|
|
6483
6483
|
}
|
|
6484
|
-
removed
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6484
|
+
for (const instance of removed) {
|
|
6485
|
+
instance.scope?.cleanup();
|
|
6486
|
+
instance.element.remove();
|
|
6487
|
+
this.instances.delete(instance.key);
|
|
6488
|
+
this.eventHandlers.delete(instance.key);
|
|
6489
|
+
this.conditionalListeners.delete(instance.key);
|
|
6490
|
+
}
|
|
6489
6491
|
this.commitCurrentCollection(dirtyState);
|
|
6490
6492
|
this.notifyConditionalChanges(conditionalChanges, afterCommit);
|
|
6491
6493
|
return true;
|
|
@@ -6534,9 +6536,14 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6534
6536
|
return;
|
|
6535
6537
|
}
|
|
6536
6538
|
if (this.reconcileStableRows(rows, afterCommit, dirtyState)) return;
|
|
6537
|
-
if (this.
|
|
6539
|
+
if (this.reconcileRemovals(rows, afterCommit, dirtyState)) return;
|
|
6538
6540
|
const nextKeys = new Set(rows.keys);
|
|
6539
6541
|
const hasSurvivingRows = rows.keys.some((key) => this.instances.has(key));
|
|
6542
|
+
const preparedBindings = nextKeys.size < this.instances.size && this.currentProps.bindings.length > 0 && !this.currentProps.hostBlocks && rows.keys.every((key) => this.instances.has(key)) ? prepareKeyedRowBindingSetUpdates(this.currentProps, this.instances, rows) : null;
|
|
6543
|
+
if (preparedBindings === void 0) {
|
|
6544
|
+
this.activateFallback(afterCommit);
|
|
6545
|
+
return;
|
|
6546
|
+
}
|
|
6540
6547
|
const oldIndices = /* @__PURE__ */ new Map();
|
|
6541
6548
|
if (hasSurvivingRows) {
|
|
6542
6549
|
[...this.instances].forEach(([key], index) => oldIndices.set(key, index));
|
|
@@ -6561,7 +6568,15 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6561
6568
|
return;
|
|
6562
6569
|
}
|
|
6563
6570
|
}
|
|
6564
|
-
|
|
6571
|
+
if (preparedBindings) {
|
|
6572
|
+
applyPreparedKeyedRowBindingUpdates(
|
|
6573
|
+
this.currentProps,
|
|
6574
|
+
existing,
|
|
6575
|
+
preparedBindings[index]
|
|
6576
|
+
);
|
|
6577
|
+
} else {
|
|
6578
|
+
applyKeyedRowBindings(this.currentProps, existing, rows.items[index], index);
|
|
6579
|
+
}
|
|
6565
6580
|
const conditionalValues = this.readConditionalValues(
|
|
6566
6581
|
this.currentProps,
|
|
6567
6582
|
rows.items[index],
|