@whitesev/domutils 2.0.4 → 2.0.5

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.
@@ -173,22 +173,12 @@ class ElementEvent extends ElementAnimate {
173
173
  if (typeof args[startIndex + 2] === "boolean") {
174
174
  option.passive = args[startIndex + 2];
175
175
  }
176
- } else if (
177
- currentParam &&
178
- typeof currentParam === "object" &&
179
- ("capture" in currentParam ||
180
- "once" in currentParam ||
181
- "passive" in currentParam ||
182
- "isComposedPath" in currentParam ||
183
- "overrideTarget" in currentParam ||
184
- "isPreventEvent" in currentParam)
185
- ) {
186
- option.capture = currentParam.capture;
187
- option.once = currentParam.once;
188
- option.passive = currentParam.passive;
189
- option.isComposedPath = currentParam.isComposedPath;
190
- option.overrideTarget = currentParam.overrideTarget;
191
- option.isPreventEvent = currentParam.isPreventEvent;
176
+ } else if (currentParam && typeof currentParam === "object") {
177
+ for (const key in option) {
178
+ if (Reflect.has(currentParam, key)) {
179
+ Reflect.set(option, key, currentParam[key as keyof typeof currentParam]);
180
+ }
181
+ }
192
182
  }
193
183
  return option;
194
184
  };
@@ -308,16 +298,16 @@ class ElementEvent extends ElementAnimate {
308
298
  // 这里尝试使用defineProperty修改event的target值
309
299
  try {
310
300
  const originTarget = event.target;
311
- OriginPrototype.Object.defineProperty(event, "target", {
312
- value: $target,
313
- get() {
314
- return $target;
301
+ OriginPrototype.Object.defineProperties(event, {
302
+ target: {
303
+ get() {
304
+ return $target;
305
+ },
315
306
  },
316
- });
317
- OriginPrototype.Object.defineProperty(event, "originTarget", {
318
- value: $target,
319
- get() {
320
- return originTarget;
307
+ originTarget: {
308
+ get() {
309
+ return originTarget;
310
+ },
321
311
  },
322
312
  });
323
313
  // oxlint-disable-next-line no-empty
@@ -521,12 +511,7 @@ class ElementEvent extends ElementAnimate {
521
511
  const currentParam: boolean | DOMUtilsEventListenerOption = args1[startIndex];
522
512
  if (typeof currentParam === "boolean") {
523
513
  option.capture = currentParam;
524
- } else if (
525
- currentParam &&
526
- typeof currentParam === "object" &&
527
- currentParam != null &&
528
- "capture" in currentParam
529
- ) {
514
+ } else if (currentParam && typeof currentParam === "object" && "capture" in currentParam) {
530
515
  option.capture = currentParam.capture;
531
516
  }
532
517
  return option;
@@ -1,5 +1,6 @@
1
1
  export const OriginPrototype = {
2
2
  Object: {
3
3
  defineProperty: Object.defineProperty,
4
+ defineProperties: Object.defineProperties,
4
5
  },
5
6
  };