@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.amd.js +9 -6
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +9 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +9 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +9 -6
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +9 -6
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +9 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/DOMUtils.ts +5 -2
- package/src/DOMUtilsEvent.ts +9 -6
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
|
|
303
|
+
if (eventTarget?.matches(selectorItem)) {
|
|
302
304
|
/* 当前目标可以被selector所匹配到 */
|
|
303
305
|
return true;
|
|
304
306
|
}
|
|
305
307
|
/* 在上层与主元素之间寻找可以被selector所匹配到的 */
|
|
306
|
-
let $closestMatches = eventTarget
|
|
307
|
-
if ($closestMatches && totalParent
|
|
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.
|
|
1063
|
+
version = "2025.5.12";
|
|
1062
1064
|
attr(element, attrName, attrValue) {
|
|
1063
1065
|
let DOMUtilsContext = this;
|
|
1064
1066
|
if (typeof element === "string") {
|
|
@@ -1202,7 +1204,8 @@ class DOMUtils extends DOMUtilsEvent {
|
|
|
1202
1204
|
return;
|
|
1203
1205
|
}
|
|
1204
1206
|
let setStyleProperty = (propertyName, propertyValue) => {
|
|
1205
|
-
if (propertyValue === "string" &&
|
|
1207
|
+
if (typeof propertyValue === "string" &&
|
|
1208
|
+
propertyValue.trim().endsWith("!important")) {
|
|
1206
1209
|
propertyValue = propertyValue
|
|
1207
1210
|
.trim()
|
|
1208
1211
|
.replace(/!important$/gi, "")
|