@farm.js/react 0.1.0-beta.30 → 0.1.0-beta.32
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.
- package/dist/compiler-runtime.cjs +33 -18
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +2 -0
- package/dist/compiler-runtime.d.ts +2 -0
- package/dist/compiler-runtime.mjs +33 -18
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/vite.cjs +69 -12
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +69 -12
- package/dist/vite.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -276,6 +276,8 @@ interface CompilerKeyedRowsBlockProps {
|
|
|
276
276
|
* row can be cloned from one already built with its bindings reapplied.
|
|
277
277
|
*/
|
|
278
278
|
cloneRows?: boolean;
|
|
279
|
+
/** Compiler-emitted lookup sharing plain-row binding path prefixes. */
|
|
280
|
+
targets?: (root: Element) => (Element | null)[];
|
|
279
281
|
}
|
|
280
282
|
interface CompilerKeyedRange {
|
|
281
283
|
/** Number of static direct host siblings between this range and the previous range. */
|
|
@@ -276,6 +276,8 @@ interface CompilerKeyedRowsBlockProps {
|
|
|
276
276
|
* row can be cloned from one already built with its bindings reapplied.
|
|
277
277
|
*/
|
|
278
278
|
cloneRows?: boolean;
|
|
279
|
+
/** Compiler-emitted lookup sharing plain-row binding path prefixes. */
|
|
280
|
+
targets?: (root: Element) => (Element | null)[];
|
|
279
281
|
}
|
|
280
282
|
interface CompilerKeyedRange {
|
|
281
283
|
/** Number of static direct host siblings between this range and the previous range. */
|
|
@@ -1725,6 +1725,9 @@ function updateAttribute(element, name, value) {
|
|
|
1725
1725
|
if (name === "value" && (isInputElement(element) || isTextAreaElement(element))) {
|
|
1726
1726
|
const nextValue = value === null || value === void 0 ? "" : String(value);
|
|
1727
1727
|
if (element.value !== nextValue) element.value = nextValue;
|
|
1728
|
+
if (value != null && isInputElement(element) && (element.type !== "number" || element.ownerDocument.activeElement !== element) && element.defaultValue !== nextValue) {
|
|
1729
|
+
element.defaultValue = nextValue;
|
|
1730
|
+
}
|
|
1728
1731
|
return;
|
|
1729
1732
|
}
|
|
1730
1733
|
if (name === "value" && isSelectElement(element)) {
|
|
@@ -1757,8 +1760,11 @@ var JAVASCRIPT_URL = (
|
|
|
1757
1760
|
);
|
|
1758
1761
|
var BLOCKS_JAVASCRIPT_URLS = Number.parseInt(React.version, 10) > 18;
|
|
1759
1762
|
function compilerAttributeValue(element, name, value) {
|
|
1763
|
+
if (!BLOCKS_JAVASCRIPT_URLS || name !== "href" && name !== "src" && name !== "action" && name !== "formAction" && name !== "data") {
|
|
1764
|
+
return value;
|
|
1765
|
+
}
|
|
1760
1766
|
const tag = element.localName;
|
|
1761
|
-
return
|
|
1767
|
+
return (name !== "data" || tag === "object") && !tag.includes("-") && JAVASCRIPT_URL.test(value) ? "javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')" : value;
|
|
1762
1768
|
}
|
|
1763
1769
|
function createConditionalBlockComponent(owner) {
|
|
1764
1770
|
class FarmConditionalBlock extends React.Component {
|
|
@@ -2548,12 +2554,15 @@ function createKeyedRowInstance(props, document, key, item, index) {
|
|
|
2548
2554
|
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
2549
2555
|
};
|
|
2550
2556
|
if (props.cloneRows) {
|
|
2551
|
-
|
|
2557
|
+
let targets = props.targets?.(element);
|
|
2552
2558
|
let found = true;
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2559
|
+
if (!targets || targets.length !== props.bindings.length || !props.bindings.every((_, index2) => targets[index2] != null)) {
|
|
2560
|
+
targets = [];
|
|
2561
|
+
for (const binding of props.bindings) {
|
|
2562
|
+
const target = findCompilerHostTarget(element, binding.path);
|
|
2563
|
+
found && (found = target !== null);
|
|
2564
|
+
targets.push(target);
|
|
2565
|
+
}
|
|
2557
2566
|
}
|
|
2558
2567
|
if (found) instance.targets = targets;
|
|
2559
2568
|
if (template) {
|
|
@@ -6145,14 +6154,18 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6145
6154
|
const eventTarget = event.target;
|
|
6146
6155
|
if (!instance || !eventTarget) return;
|
|
6147
6156
|
const capture = name.endsWith("Capture");
|
|
6148
|
-
const
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
)
|
|
6155
|
-
|
|
6157
|
+
const descriptors = this.currentProps.events || [];
|
|
6158
|
+
const matches = [];
|
|
6159
|
+
for (let index = 0, length = descriptors.length; index < length; index += 1) {
|
|
6160
|
+
if (!(index in descriptors)) continue;
|
|
6161
|
+
const descriptor = descriptors[index];
|
|
6162
|
+
if (descriptor.name !== name || descriptor.path === void 0) continue;
|
|
6163
|
+
const target = findCompilerHostTarget(instance.element, descriptor.path || []);
|
|
6164
|
+
if (target && (target === eventTarget || target.contains(eventTarget))) {
|
|
6165
|
+
matches.push({ descriptor, target });
|
|
6166
|
+
}
|
|
6167
|
+
}
|
|
6168
|
+
matches.sort(
|
|
6156
6169
|
(left, right) => capture ? (left.descriptor.path?.length || 0) - (right.descriptor.path?.length || 0) : (right.descriptor.path?.length || 0) - (left.descriptor.path?.length || 0)
|
|
6157
6170
|
);
|
|
6158
6171
|
for (const match of matches) {
|
|
@@ -6876,10 +6889,12 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6876
6889
|
let oldIndex = 0;
|
|
6877
6890
|
for (const key of this.instances.keys()) oldIndices.set(key, oldIndex++);
|
|
6878
6891
|
}
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6892
|
+
if (hasSurvivingRows || options.hostBlocks) {
|
|
6893
|
+
for (const [key, instance] of this.instances) {
|
|
6894
|
+
if (!nextKeys.has(key)) {
|
|
6895
|
+
instance.scope?.cleanup();
|
|
6896
|
+
if (hasSurvivingRows) instance.element.remove();
|
|
6897
|
+
}
|
|
6883
6898
|
}
|
|
6884
6899
|
}
|
|
6885
6900
|
const sequence = hasSurvivingRows ? rows.keys.map((key) => oldIndices.get(key) ?? -1) : [];
|