@whitesev/domutils 1.4.4 → 1.4.6

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.umd.js CHANGED
@@ -280,7 +280,7 @@
280
280
  const selectorItem = selectorList[index];
281
281
  if (eventTarget.matches(selectorItem)) {
282
282
  /* 当前目标可以被selector所匹配到 */
283
- listenerCallBack.call(eventTarget, event);
283
+ listenerCallBack.call(eventTarget, event, eventTarget);
284
284
  checkOptionOnceToRemoveEventListener();
285
285
  break;
286
286
  }
@@ -289,12 +289,16 @@
289
289
  let $closestMatches = eventTarget.closest(selectorItem);
290
290
  if ($closestMatches && totalParent.contains($closestMatches)) {
291
291
  /* event的target值不能直接修改 */
292
- OriginPrototype.Object.defineProperty(event, "target", {
293
- get() {
294
- return $closestMatches;
295
- },
296
- });
297
- listenerCallBack.call($closestMatches, event);
292
+ // 这里尝试使用defineProperty修改eventtarget
293
+ try {
294
+ OriginPrototype.Object.defineProperty(event, "target", {
295
+ get() {
296
+ return $closestMatches;
297
+ },
298
+ });
299
+ }
300
+ catch (error) { }
301
+ listenerCallBack.call($closestMatches, event, $closestMatches);
298
302
  checkOptionOnceToRemoveEventListener();
299
303
  break;
300
304
  }
@@ -1034,7 +1038,7 @@
1034
1038
  super(option);
1035
1039
  }
1036
1040
  /** 版本号 */
1037
- version = "2024.12.3";
1041
+ version = "2024.12.4";
1038
1042
  attr(element, attrName, attrValue) {
1039
1043
  let DOMUtilsContext = this;
1040
1044
  if (typeof element === "string") {