@farm.js/react 0.1.0-beta.25 → 0.1.0-beta.26
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.
|
@@ -2624,18 +2624,21 @@ function commitKeyedRowBinding(binding, instance, bindingIndex, value, target) {
|
|
|
2624
2624
|
instance.values[bindingIndex] = value;
|
|
2625
2625
|
if (!target) return;
|
|
2626
2626
|
if (binding.kind === "text") {
|
|
2627
|
-
|
|
2628
|
-
if (value && text && text === target.lastChild && text.nodeType === 3) {
|
|
2629
|
-
text.data = value;
|
|
2630
|
-
} else {
|
|
2631
|
-
target.textContent = value;
|
|
2632
|
-
}
|
|
2627
|
+
updateTextContent(target, value);
|
|
2633
2628
|
} else if (binding.kind === "style" && binding.name) {
|
|
2634
2629
|
updateStyle(target, binding.name, value);
|
|
2635
2630
|
} else if (binding.kind === "attribute" && binding.name) {
|
|
2636
2631
|
updateAttribute(target, binding.name, value);
|
|
2637
2632
|
}
|
|
2638
2633
|
}
|
|
2634
|
+
function updateTextContent(target, value) {
|
|
2635
|
+
const text = target.firstChild;
|
|
2636
|
+
if (value && text && text === target.lastChild && text.nodeType === 3) {
|
|
2637
|
+
text.data = value;
|
|
2638
|
+
} else {
|
|
2639
|
+
target.textContent = value;
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2639
2642
|
function prepareKeyedRowBindingUpdate(props, instance, item, index, bindingIndex) {
|
|
2640
2643
|
const binding = props.bindings[bindingIndex];
|
|
2641
2644
|
const rawValue = binding.read(item, index);
|
|
@@ -8320,6 +8323,7 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
|
|
|
8320
8323
|
this.trackedBindingsByDependency = [];
|
|
8321
8324
|
this.trackedDependenciesByBinding = /* @__PURE__ */ new Map();
|
|
8322
8325
|
this.bindingValues = /* @__PURE__ */ new Map();
|
|
8326
|
+
this.textNodes = /* @__PURE__ */ new Map();
|
|
8323
8327
|
this.activeBinding = null;
|
|
8324
8328
|
this.activeDependencies = null;
|
|
8325
8329
|
this.renderedDefinition = null;
|
|
@@ -8382,13 +8386,8 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
|
|
|
8382
8386
|
}
|
|
8383
8387
|
this.blockRuntime = blockRuntime;
|
|
8384
8388
|
}
|
|
8385
|
-
usesHybridReactivity() {
|
|
8386
|
-
return definitionReference.current.reactivity === "hybrid";
|
|
8387
|
-
}
|
|
8388
8389
|
canReuseRenderedElement(currentDefinition, propValues) {
|
|
8389
|
-
return
|
|
8390
|
-
this.mounted && propValues && propValues.every(isCompilerPrimitive) && this.renderedDefinition === currentDefinition && this.renderedElement
|
|
8391
|
-
);
|
|
8390
|
+
return this.mounted && propValues !== null && propValues.every(isCompilerPrimitive) && this.renderedDefinition === currentDefinition;
|
|
8392
8391
|
}
|
|
8393
8392
|
renderCellsForProps(propValues) {
|
|
8394
8393
|
if (!propValues) return { cells: this.cells, commit: () => void 0 };
|
|
@@ -8410,7 +8409,7 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
|
|
|
8410
8409
|
};
|
|
8411
8410
|
}
|
|
8412
8411
|
tracksBinding(binding) {
|
|
8413
|
-
return
|
|
8412
|
+
return definitionReference.current.reactivity === "hybrid" && binding.tracking === "dynamic";
|
|
8414
8413
|
}
|
|
8415
8414
|
ensureBindingIndex() {
|
|
8416
8415
|
const currentDefinition = definitionReference.current;
|
|
@@ -8472,7 +8471,7 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
|
|
|
8472
8471
|
return binding.kind === "text" ? renderTextValue(value) : value;
|
|
8473
8472
|
}
|
|
8474
8473
|
primeHybridBindings() {
|
|
8475
|
-
if (
|
|
8474
|
+
if (definitionReference.current.reactivity !== "hybrid") return;
|
|
8476
8475
|
for (const binding of definitionReference.current.bindings) {
|
|
8477
8476
|
if (binding.kind === "block") continue;
|
|
8478
8477
|
if (!this.tracksBinding(binding)) continue;
|
|
@@ -8561,29 +8560,26 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
|
|
|
8561
8560
|
for (const binding of this.staticBindingsByDependency[dependency] || []) {
|
|
8562
8561
|
affectedBindings.add(binding);
|
|
8563
8562
|
}
|
|
8564
|
-
if (
|
|
8563
|
+
if (definitionReference.current.reactivity === "hybrid") {
|
|
8565
8564
|
for (const binding of this.trackedBindingsByDependency[dependency] || []) {
|
|
8566
8565
|
affectedBindings.add(binding);
|
|
8567
8566
|
}
|
|
8568
8567
|
}
|
|
8569
8568
|
}
|
|
8570
|
-
const
|
|
8569
|
+
const blockRefreshes = [];
|
|
8570
|
+
for (const id of affectedBlockIds) {
|
|
8571
|
+
const binding = this.blockBindings.get(id);
|
|
8572
|
+
const refresh = this.blockRefreshListeners.get(id);
|
|
8573
|
+
if (!binding || !refresh) continue;
|
|
8571
8574
|
let parent = binding.parent;
|
|
8572
8575
|
while (parent !== void 0) {
|
|
8573
|
-
if (affectedBlockIds.has(parent) && this.blockRefreshListeners.has(parent))
|
|
8574
|
-
return true;
|
|
8575
|
-
}
|
|
8576
|
+
if (affectedBlockIds.has(parent) && this.blockRefreshListeners.has(parent)) break;
|
|
8576
8577
|
parent = this.blockBindings.get(parent)?.parent;
|
|
8577
8578
|
}
|
|
8578
|
-
|
|
8579
|
-
}
|
|
8580
|
-
const blockRefreshes = [...affectedBlockIds].map((id) => {
|
|
8581
|
-
const binding = this.blockBindings.get(id);
|
|
8582
|
-
const refresh = this.blockRefreshListeners.get(id);
|
|
8583
|
-
return binding && refresh && !hasAffectedMountedAncestor(binding) ? refresh : void 0;
|
|
8584
|
-
}).filter((refresh) => refresh !== void 0);
|
|
8579
|
+
if (parent === void 0) blockRefreshes.push(refresh);
|
|
8580
|
+
}
|
|
8585
8581
|
for (const binding of affectedBindings) {
|
|
8586
|
-
|
|
8582
|
+
this.applyBinding(binding);
|
|
8587
8583
|
}
|
|
8588
8584
|
let pendingBlockCommits = blockRefreshes.length;
|
|
8589
8585
|
for (const refresh of blockRefreshes) {
|
|
@@ -8609,7 +8605,12 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
|
|
|
8609
8605
|
if (Object.is(this.bindingValues.get(binding), comparableValue)) return;
|
|
8610
8606
|
}
|
|
8611
8607
|
if (binding.kind === "text") {
|
|
8612
|
-
target
|
|
8608
|
+
if (!this.textNodes.has(target)) {
|
|
8609
|
+
this.textNodes.set(target, [...target.childNodes]);
|
|
8610
|
+
target.textContent = comparableValue;
|
|
8611
|
+
} else {
|
|
8612
|
+
updateTextContent(target, comparableValue);
|
|
8613
|
+
}
|
|
8613
8614
|
} else if (binding.kind === "style") {
|
|
8614
8615
|
updateStyle(target, binding.name, value);
|
|
8615
8616
|
} else {
|
|
@@ -8626,9 +8627,16 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
|
|
|
8626
8627
|
getSnapshotBeforeUpdate() {
|
|
8627
8628
|
const currentDefinition = definitionReference.current;
|
|
8628
8629
|
const propValues = currentDefinition.readProps?.(this.props) || null;
|
|
8629
|
-
|
|
8630
|
+
if (this.canReuseRenderedElement(currentDefinition, propValues)) return true;
|
|
8631
|
+
this.textNodes.forEach((children, target) => {
|
|
8632
|
+
target.textContent = "";
|
|
8633
|
+
for (const child of children) target.appendChild(child);
|
|
8634
|
+
});
|
|
8635
|
+
this.textNodes.clear();
|
|
8636
|
+
this.bindingValues.clear();
|
|
8637
|
+
return false;
|
|
8630
8638
|
}
|
|
8631
|
-
componentDidUpdate(_previousProps, _previousState, reusedRenderedElement
|
|
8639
|
+
componentDidUpdate(_previousProps, _previousState, reusedRenderedElement) {
|
|
8632
8640
|
const propValues = definitionReference.current.readProps?.(this.props) || null;
|
|
8633
8641
|
if (propValues) {
|
|
8634
8642
|
if (reusedRenderedElement) this.captureInputSelection();
|
|
@@ -8643,12 +8651,16 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
|
|
|
8643
8651
|
cell.flush();
|
|
8644
8652
|
}
|
|
8645
8653
|
}
|
|
8654
|
+
if (!reusedRenderedElement) {
|
|
8655
|
+
this.ensureBindingIndex();
|
|
8656
|
+
this.primeHybridBindings();
|
|
8657
|
+
}
|
|
8646
8658
|
this.flushBindingUpdates();
|
|
8647
8659
|
return;
|
|
8648
8660
|
}
|
|
8649
8661
|
this.ensureBindingIndex();
|
|
8650
8662
|
for (const binding of definitionReference.current.bindings) {
|
|
8651
|
-
|
|
8663
|
+
this.applyBinding(binding, true);
|
|
8652
8664
|
}
|
|
8653
8665
|
}
|
|
8654
8666
|
componentWillUnmount() {
|
|
@@ -8664,6 +8676,7 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
|
|
|
8664
8676
|
this.trackedBindingsByDependency = [];
|
|
8665
8677
|
this.trackedDependenciesByBinding.clear();
|
|
8666
8678
|
this.bindingValues.clear();
|
|
8679
|
+
this.textNodes.clear();
|
|
8667
8680
|
this.activeBinding = null;
|
|
8668
8681
|
this.activeDependencies = null;
|
|
8669
8682
|
refreshListeners.delete(this.refreshDefinition);
|