@farm.js/react 0.1.0-beta.31 → 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 +30 -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 +30 -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. */
|
|
@@ -1760,8 +1760,11 @@ var JAVASCRIPT_URL = (
|
|
|
1760
1760
|
);
|
|
1761
1761
|
var BLOCKS_JAVASCRIPT_URLS = Number.parseInt(React.version, 10) > 18;
|
|
1762
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
|
+
}
|
|
1763
1766
|
const tag = element.localName;
|
|
1764
|
-
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;
|
|
1765
1768
|
}
|
|
1766
1769
|
function createConditionalBlockComponent(owner) {
|
|
1767
1770
|
class FarmConditionalBlock extends React.Component {
|
|
@@ -2551,12 +2554,15 @@ function createKeyedRowInstance(props, document, key, item, index) {
|
|
|
2551
2554
|
conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
|
|
2552
2555
|
};
|
|
2553
2556
|
if (props.cloneRows) {
|
|
2554
|
-
|
|
2557
|
+
let targets = props.targets?.(element);
|
|
2555
2558
|
let found = true;
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
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
|
+
}
|
|
2560
2566
|
}
|
|
2561
2567
|
if (found) instance.targets = targets;
|
|
2562
2568
|
if (template) {
|
|
@@ -6148,14 +6154,18 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6148
6154
|
const eventTarget = event.target;
|
|
6149
6155
|
if (!instance || !eventTarget) return;
|
|
6150
6156
|
const capture = name.endsWith("Capture");
|
|
6151
|
-
const
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
)
|
|
6158
|
-
|
|
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(
|
|
6159
6169
|
(left, right) => capture ? (left.descriptor.path?.length || 0) - (right.descriptor.path?.length || 0) : (right.descriptor.path?.length || 0) - (left.descriptor.path?.length || 0)
|
|
6160
6170
|
);
|
|
6161
6171
|
for (const match of matches) {
|
|
@@ -6879,10 +6889,12 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6879
6889
|
let oldIndex = 0;
|
|
6880
6890
|
for (const key of this.instances.keys()) oldIndices.set(key, oldIndex++);
|
|
6881
6891
|
}
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
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
|
+
}
|
|
6886
6898
|
}
|
|
6887
6899
|
}
|
|
6888
6900
|
const sequence = hasSurvivingRows ? rows.keys.map((key) => oldIndices.get(key) ?? -1) : [];
|