@tarojs/runtime 3.4.10 → 3.4.13

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.
@@ -1,6 +1,8 @@
1
1
  import type { TaroElement } from './element';
2
2
  import type { EventOptions, MpEvent } from '../interface';
3
3
  export declare class TaroEvent {
4
+ private cacheTarget;
5
+ private cacheCurrentTarget;
4
6
  type: string;
5
7
  bubbles: boolean;
6
8
  cancelable: boolean;
@@ -2833,26 +2833,43 @@ class TaroEvent {
2833
2833
  }
2834
2834
  get target() {
2835
2835
  var _a, _b;
2836
- const target = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target) || null);
2837
- const element = getDocument().getElementById(target.id);
2838
- target.dataset = element !== null ? element.dataset : EMPTY_OBJ;
2839
- for (const key in (_b = this.mpEvent) === null || _b === void 0 ? void 0 : _b.detail) {
2840
- target[key] = this.mpEvent.detail[key];
2836
+ const cacheTarget = this.cacheTarget;
2837
+ if (!cacheTarget) {
2838
+ const target = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target) || null);
2839
+ const element = getDocument().getElementById(target.id);
2840
+ target.dataset = element !== null ? element.dataset : EMPTY_OBJ;
2841
+ for (const key in (_b = this.mpEvent) === null || _b === void 0 ? void 0 : _b.detail) {
2842
+ target[key] = this.mpEvent.detail[key];
2843
+ }
2844
+ this.cacheTarget = target;
2845
+ return target;
2846
+ }
2847
+ else {
2848
+ return cacheTarget;
2841
2849
  }
2842
- return target;
2843
2850
  }
2844
2851
  get currentTarget() {
2845
- var _a, _b;
2846
- const currentTarget = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.currentTarget) || null);
2847
- const element = getDocument().getElementById(currentTarget.id);
2848
- if (element === null) {
2849
- return this.target;
2852
+ var _a, _b, _c, _d;
2853
+ const cacheCurrentTarget = this.cacheCurrentTarget;
2854
+ if (!cacheCurrentTarget) {
2855
+ const doc = getDocument();
2856
+ const currentTarget = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.currentTarget) || null);
2857
+ const element = doc.getElementById(currentTarget.id);
2858
+ const targetElement = doc.getElementById(((_c = (_b = this.mpEvent) === null || _b === void 0 ? void 0 : _b.target) === null || _c === void 0 ? void 0 : _c.id) || null);
2859
+ if (element === null || (element && element === targetElement)) {
2860
+ this.cacheCurrentTarget = this.target;
2861
+ return this.target;
2862
+ }
2863
+ currentTarget.dataset = element.dataset;
2864
+ for (const key in (_d = this.mpEvent) === null || _d === void 0 ? void 0 : _d.detail) {
2865
+ currentTarget[key] = this.mpEvent.detail[key];
2866
+ }
2867
+ this.cacheCurrentTarget = currentTarget;
2868
+ return currentTarget;
2850
2869
  }
2851
- currentTarget.dataset = element.dataset;
2852
- for (const key in (_b = this.mpEvent) === null || _b === void 0 ? void 0 : _b.detail) {
2853
- currentTarget[key] = this.mpEvent.detail[key];
2870
+ else {
2871
+ return cacheCurrentTarget;
2854
2872
  }
2855
- return currentTarget;
2856
2873
  }
2857
2874
  }
2858
2875
  function createEvent(event, node) {