@whitesev/domutils 1.5.2 → 1.5.4

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.cjs.js CHANGED
@@ -295,18 +295,20 @@ class DOMUtilsEvent {
295
295
  let eventTarget = listenerOption.isComposedPath
296
296
  ? event.composedPath()[0]
297
297
  : event.target;
298
- let totalParent = DOMUtilsCommonUtils.isWin(elementItem)
298
+ let totalParent = DOMUtilsCommonUtils.isWin(elementItem) ||
299
+ // @ts-ignore
300
+ elementItem === DOMUtilsContext.windowApi.document
299
301
  ? DOMUtilsContext.windowApi.document.documentElement
300
302
  : elementItem;
301
303
  let findValue = selectorList.find((selectorItem) => {
302
304
  // 判断目标元素是否匹配选择器
303
- if (eventTarget.matches(selectorItem)) {
305
+ if (eventTarget?.matches(selectorItem)) {
304
306
  /* 当前目标可以被selector所匹配到 */
305
307
  return true;
306
308
  }
307
309
  /* 在上层与主元素之间寻找可以被selector所匹配到的 */
308
- let $closestMatches = eventTarget.closest(selectorItem);
309
- if ($closestMatches && totalParent.contains($closestMatches)) {
310
+ let $closestMatches = eventTarget?.closest(selectorItem);
311
+ if ($closestMatches && totalParent?.contains($closestMatches)) {
310
312
  eventTarget = $closestMatches;
311
313
  return true;
312
314
  }
@@ -1060,7 +1062,7 @@ class DOMUtils extends DOMUtilsEvent {
1060
1062
  super(option);
1061
1063
  }
1062
1064
  /** 版本号 */
1063
- version = "2025.4.8";
1065
+ version = "2025.5.12";
1064
1066
  attr(element, attrName, attrValue) {
1065
1067
  let DOMUtilsContext = this;
1066
1068
  if (typeof element === "string") {
@@ -1204,7 +1206,8 @@ class DOMUtils extends DOMUtilsEvent {
1204
1206
  return;
1205
1207
  }
1206
1208
  let setStyleProperty = (propertyName, propertyValue) => {
1207
- if (propertyValue === "string" && propertyValue.includes("!important")) {
1209
+ if (typeof propertyValue === "string" &&
1210
+ propertyValue.trim().endsWith("!important")) {
1208
1211
  propertyValue = propertyValue
1209
1212
  .trim()
1210
1213
  .replace(/!important$/gi, "")