@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.
@@ -1766,8 +1766,11 @@ var JAVASCRIPT_URL = (
1766
1766
  );
1767
1767
  var BLOCKS_JAVASCRIPT_URLS = Number.parseInt(React__default.default.version, 10) > 18;
1768
1768
  function compilerAttributeValue(element, name, value) {
1769
+ if (!BLOCKS_JAVASCRIPT_URLS || name !== "href" && name !== "src" && name !== "action" && name !== "formAction" && name !== "data") {
1770
+ return value;
1771
+ }
1769
1772
  const tag = element.localName;
1770
- return BLOCKS_JAVASCRIPT_URLS && (name === "href" || name === "src" || name === "action" || name === "formAction" || 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;
1773
+ 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;
1771
1774
  }
1772
1775
  function createConditionalBlockComponent(owner) {
1773
1776
  class FarmConditionalBlock extends React__default.default.Component {
@@ -2557,12 +2560,15 @@ function createKeyedRowInstance(props, document, key, item, index) {
2557
2560
  conditionalValues: EMPTY_KEYED_ROW_CONDITIONAL_VALUES
2558
2561
  };
2559
2562
  if (props.cloneRows) {
2560
- const targets = [];
2563
+ let targets = props.targets?.(element);
2561
2564
  let found = true;
2562
- for (const binding of props.bindings) {
2563
- const target = findCompilerHostTarget(element, binding.path);
2564
- found && (found = target !== null);
2565
- targets.push(target);
2565
+ if (!targets || targets.length !== props.bindings.length || !props.bindings.every((_, index2) => targets[index2] != null)) {
2566
+ targets = [];
2567
+ for (const binding of props.bindings) {
2568
+ const target = findCompilerHostTarget(element, binding.path);
2569
+ found && (found = target !== null);
2570
+ targets.push(target);
2571
+ }
2566
2572
  }
2567
2573
  if (found) instance.targets = targets;
2568
2574
  if (template) {
@@ -6154,14 +6160,18 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
6154
6160
  const eventTarget = event.target;
6155
6161
  if (!instance || !eventTarget) return;
6156
6162
  const capture = name.endsWith("Capture");
6157
- const matches = (this.currentProps.events || []).filter((descriptor) => descriptor.name === name && descriptor.path !== void 0).map((descriptor) => ({
6158
- descriptor,
6159
- target: findCompilerHostTarget(instance.element, descriptor.path || [])
6160
- })).filter(
6161
- (match) => Boolean(
6162
- match.target && (match.target === eventTarget || match.target.contains(eventTarget))
6163
- )
6164
- ).sort(
6163
+ const descriptors = this.currentProps.events || [];
6164
+ const matches = [];
6165
+ for (let index = 0, length = descriptors.length; index < length; index += 1) {
6166
+ if (!(index in descriptors)) continue;
6167
+ const descriptor = descriptors[index];
6168
+ if (descriptor.name !== name || descriptor.path === void 0) continue;
6169
+ const target = findCompilerHostTarget(instance.element, descriptor.path || []);
6170
+ if (target && (target === eventTarget || target.contains(eventTarget))) {
6171
+ matches.push({ descriptor, target });
6172
+ }
6173
+ }
6174
+ matches.sort(
6165
6175
  (left, right) => capture ? (left.descriptor.path?.length || 0) - (right.descriptor.path?.length || 0) : (right.descriptor.path?.length || 0) - (left.descriptor.path?.length || 0)
6166
6176
  );
6167
6177
  for (const match of matches) {
@@ -6885,10 +6895,12 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
6885
6895
  let oldIndex = 0;
6886
6896
  for (const key of this.instances.keys()) oldIndices.set(key, oldIndex++);
6887
6897
  }
6888
- for (const [key, instance] of this.instances) {
6889
- if (!nextKeys.has(key)) {
6890
- instance.scope?.cleanup();
6891
- if (hasSurvivingRows) instance.element.remove();
6898
+ if (hasSurvivingRows || options.hostBlocks) {
6899
+ for (const [key, instance] of this.instances) {
6900
+ if (!nextKeys.has(key)) {
6901
+ instance.scope?.cleanup();
6902
+ if (hasSurvivingRows) instance.element.remove();
6903
+ }
6892
6904
  }
6893
6905
  }
6894
6906
  const sequence = hasSurvivingRows ? rows.keys.map((key) => oldIndices.get(key) ?? -1) : [];