@next-core/brick-kit 2.139.0 → 2.140.0

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/index.esm.js CHANGED
@@ -6719,24 +6719,42 @@ function customListenerFactory(handler, ifContainer, context, runtimeBrick) {
6719
6719
  }
6720
6720
 
6721
6721
  var targets = [];
6722
+ var rawTarget = handler.target;
6723
+ var rawTargetRef = handler.targetRef;
6724
+ var computedTarget = rawTarget; // Allow `target` to be set as evaluable string.
6722
6725
 
6723
- if (typeof handler.target === "string") {
6724
- if (handler.target === "_self") {
6726
+ if (typeof rawTarget === "string" ? isEvaluable(rawTarget) : isPreEvaluated(rawTarget)) {
6727
+ computedTarget = computeRealValue(rawTarget, context);
6728
+ }
6729
+
6730
+ if (typeof computedTarget === "string") {
6731
+ if (computedTarget === "_self") {
6725
6732
  targets.push(runtimeBrick.element);
6726
6733
  } else if (handler.multiple) {
6727
- targets = Array.from(document.querySelectorAll(handler.target));
6734
+ targets = Array.from(document.querySelectorAll(computedTarget));
6728
6735
  } else {
6729
- var found = document.querySelector(handler.target);
6736
+ var found = document.querySelector(computedTarget);
6730
6737
 
6731
6738
  if (found !== null) {
6732
6739
  targets.push(found);
6733
6740
  }
6734
6741
  }
6735
- } else if (handler.target) {
6736
- targets.push(handler.target);
6737
- } else if (handler.targetRef) {
6742
+ } else if (computedTarget) {
6743
+ if (computedTarget instanceof HTMLElement) {
6744
+ targets.push(computedTarget);
6745
+ } else {
6746
+ // eslint-disable-next-line no-console
6747
+ console.error("unexpected target:", computedTarget);
6748
+ }
6749
+ } else if (rawTargetRef) {
6750
+ var computedTargetRef = rawTargetRef; // Allow `targetRef` to be set as evaluable string.
6751
+
6752
+ if (typeof rawTargetRef === "string" ? isEvaluable(rawTargetRef) : isPreEvaluated(rawTargetRef)) {
6753
+ computedTargetRef = computeRealValue(rawTargetRef, context, true);
6754
+ }
6755
+
6738
6756
  var tpl = getTplContext(context.tplContextId).getBrick().element;
6739
- targets.push(...[].concat(handler.targetRef).map(ref => {
6757
+ targets.push(...[].concat(computedTargetRef).map(ref => {
6740
6758
  var _tpl$$$getElementByRe;
6741
6759
 
6742
6760
  return (_tpl$$$getElementByRe = tpl.$$getElementByRef) === null || _tpl$$$getElementByRe === void 0 ? void 0 : _tpl$$$getElementByRe.call(tpl, ref);
@@ -6745,7 +6763,7 @@ function customListenerFactory(handler, ifContainer, context, runtimeBrick) {
6745
6763
 
6746
6764
  if (targets.length === 0) {
6747
6765
  // eslint-disable-next-line no-console
6748
- console.error("target not found:", handler.target || handler.targetRef);
6766
+ console.error("target not found:", rawTarget || rawTargetRef);
6749
6767
  return;
6750
6768
  }
6751
6769