@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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.140.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.139.0...@next-core/brick-kit@2.140.0) (2022-09-14)
7
+
8
+
9
+ ### Features
10
+
11
+ * allow target/targetRef to be set as evaluable string ([ef06f22](https://github.com/easyops-cn/next-core/commit/ef06f22d8401880a7c450a04f09ed08c9748846c))
12
+
13
+
14
+
15
+
16
+
6
17
  # [2.139.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.138.0...@next-core/brick-kit@2.139.0) (2022-09-13)
7
18
 
8
19
 
@@ -6718,24 +6718,42 @@
6718
6718
  }
6719
6719
 
6720
6720
  var targets = [];
6721
+ var rawTarget = handler.target;
6722
+ var rawTargetRef = handler.targetRef;
6723
+ var computedTarget = rawTarget; // Allow `target` to be set as evaluable string.
6721
6724
 
6722
- if (typeof handler.target === "string") {
6723
- if (handler.target === "_self") {
6725
+ if (typeof rawTarget === "string" ? brickUtils.isEvaluable(rawTarget) : isPreEvaluated(rawTarget)) {
6726
+ computedTarget = computeRealValue(rawTarget, context);
6727
+ }
6728
+
6729
+ if (typeof computedTarget === "string") {
6730
+ if (computedTarget === "_self") {
6724
6731
  targets.push(runtimeBrick.element);
6725
6732
  } else if (handler.multiple) {
6726
- targets = Array.from(document.querySelectorAll(handler.target));
6733
+ targets = Array.from(document.querySelectorAll(computedTarget));
6727
6734
  } else {
6728
- var found = document.querySelector(handler.target);
6735
+ var found = document.querySelector(computedTarget);
6729
6736
 
6730
6737
  if (found !== null) {
6731
6738
  targets.push(found);
6732
6739
  }
6733
6740
  }
6734
- } else if (handler.target) {
6735
- targets.push(handler.target);
6736
- } else if (handler.targetRef) {
6741
+ } else if (computedTarget) {
6742
+ if (computedTarget instanceof HTMLElement) {
6743
+ targets.push(computedTarget);
6744
+ } else {
6745
+ // eslint-disable-next-line no-console
6746
+ console.error("unexpected target:", computedTarget);
6747
+ }
6748
+ } else if (rawTargetRef) {
6749
+ var computedTargetRef = rawTargetRef; // Allow `targetRef` to be set as evaluable string.
6750
+
6751
+ if (typeof rawTargetRef === "string" ? brickUtils.isEvaluable(rawTargetRef) : isPreEvaluated(rawTargetRef)) {
6752
+ computedTargetRef = computeRealValue(rawTargetRef, context, true);
6753
+ }
6754
+
6737
6755
  var tpl = getTplContext(context.tplContextId).getBrick().element;
6738
- targets.push(...[].concat(handler.targetRef).map(ref => {
6756
+ targets.push(...[].concat(computedTargetRef).map(ref => {
6739
6757
  var _tpl$$$getElementByRe;
6740
6758
 
6741
6759
  return (_tpl$$$getElementByRe = tpl.$$getElementByRef) === null || _tpl$$$getElementByRe === void 0 ? void 0 : _tpl$$$getElementByRe.call(tpl, ref);
@@ -6744,7 +6762,7 @@
6744
6762
 
6745
6763
  if (targets.length === 0) {
6746
6764
  // eslint-disable-next-line no-console
6747
- console.error("target not found:", handler.target || handler.targetRef);
6765
+ console.error("target not found:", rawTarget || rawTargetRef);
6748
6766
  return;
6749
6767
  }
6750
6768