@whitesev/domutils 1.5.2 → 1.5.3

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
@@ -293,18 +293,20 @@ class DOMUtilsEvent {
293
293
  let eventTarget = listenerOption.isComposedPath
294
294
  ? event.composedPath()[0]
295
295
  : event.target;
296
- let totalParent = DOMUtilsCommonUtils.isWin(elementItem)
296
+ let totalParent = DOMUtilsCommonUtils.isWin(elementItem) ||
297
+ // @ts-ignore
298
+ elementItem === DOMUtilsContext.windowApi.document
297
299
  ? DOMUtilsContext.windowApi.document.documentElement
298
300
  : elementItem;
299
301
  let findValue = selectorList.find((selectorItem) => {
300
302
  // 判断目标元素是否匹配选择器
301
- if (eventTarget.matches(selectorItem)) {
303
+ if (eventTarget?.matches(selectorItem)) {
302
304
  /* 当前目标可以被selector所匹配到 */
303
305
  return true;
304
306
  }
305
307
  /* 在上层与主元素之间寻找可以被selector所匹配到的 */
306
- let $closestMatches = eventTarget.closest(selectorItem);
307
- if ($closestMatches && totalParent.contains($closestMatches)) {
308
+ let $closestMatches = eventTarget?.closest(selectorItem);
309
+ if ($closestMatches && totalParent?.contains($closestMatches)) {
308
310
  eventTarget = $closestMatches;
309
311
  return true;
310
312
  }
@@ -1058,7 +1060,7 @@ class DOMUtils extends DOMUtilsEvent {
1058
1060
  super(option);
1059
1061
  }
1060
1062
  /** 版本号 */
1061
- version = "2025.4.8";
1063
+ version = "2025.4.23";
1062
1064
  attr(element, attrName, attrValue) {
1063
1065
  let DOMUtilsContext = this;
1064
1066
  if (typeof element === "string") {