@whitesev/utils 1.9.6 → 1.9.7
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 +8 -15
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +8 -15
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +8 -15
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +8 -15
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +8 -15
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +8 -15
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -3818,7 +3818,9 @@ var Utils = (function () {
|
|
|
3818
3818
|
/* CODE FOR BROWSERS THAT SUPPORT window.find */
|
|
3819
3819
|
let windowFind = UtilsCore.self.find;
|
|
3820
3820
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
3821
|
-
if (strFound &&
|
|
3821
|
+
if (strFound &&
|
|
3822
|
+
UtilsCore.self.getSelection &&
|
|
3823
|
+
!UtilsCore.self.getSelection().anchorNode) {
|
|
3822
3824
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
3823
3825
|
}
|
|
3824
3826
|
if (!strFound) {
|
|
@@ -4890,7 +4892,8 @@ var Utils = (function () {
|
|
|
4890
4892
|
return result;
|
|
4891
4893
|
}
|
|
4892
4894
|
isThemeDark() {
|
|
4893
|
-
return UtilsCore.globalThis.matchMedia("(prefers-color-scheme: dark)")
|
|
4895
|
+
return UtilsCore.globalThis.matchMedia("(prefers-color-scheme: dark)")
|
|
4896
|
+
.matches;
|
|
4894
4897
|
}
|
|
4895
4898
|
isVisible(element, inView = false) {
|
|
4896
4899
|
let needCheckDomList = [];
|
|
@@ -5089,11 +5092,6 @@ var Utils = (function () {
|
|
|
5089
5092
|
}
|
|
5090
5093
|
mutationObserver(target, observer_config) {
|
|
5091
5094
|
let UtilsContext = this;
|
|
5092
|
-
if (!(target instanceof Node) &&
|
|
5093
|
-
!(target instanceof NodeList) &&
|
|
5094
|
-
!UtilsContext.isJQuery(target)) {
|
|
5095
|
-
throw new Error("Utils.mutationObserver 参数 target 必须为 Node|NodeList|jQuery类型");
|
|
5096
|
-
}
|
|
5097
5095
|
let default_obverser_config = {
|
|
5098
5096
|
/* 监听到元素有反馈,需执行的函数 */
|
|
5099
5097
|
callback: () => { },
|
|
@@ -5142,12 +5140,8 @@ var Utils = (function () {
|
|
|
5142
5140
|
let mutationObserver = new windowMutationObserver(function (mutations, observer) {
|
|
5143
5141
|
observer_config?.callback(mutations, observer);
|
|
5144
5142
|
});
|
|
5145
|
-
if (target instanceof
|
|
5146
|
-
|
|
5147
|
-
mutationObserver.observe(target, observer_config.config);
|
|
5148
|
-
}
|
|
5149
|
-
else if (target instanceof NodeList) {
|
|
5150
|
-
/* 传入的参数是节点元素数组 */
|
|
5143
|
+
if (Array.isArray(target) || target instanceof NodeList) {
|
|
5144
|
+
// 传入的是数组或者元素数组
|
|
5151
5145
|
target.forEach((item) => {
|
|
5152
5146
|
mutationObserver.observe(item, observer_config.config);
|
|
5153
5147
|
});
|
|
@@ -5159,8 +5153,7 @@ var Utils = (function () {
|
|
|
5159
5153
|
});
|
|
5160
5154
|
}
|
|
5161
5155
|
else {
|
|
5162
|
-
|
|
5163
|
-
console.error("Utils.mutationObserver 未知参数", arguments);
|
|
5156
|
+
mutationObserver.observe(target, observer_config.config);
|
|
5164
5157
|
}
|
|
5165
5158
|
if (observer_config.immediate) {
|
|
5166
5159
|
/* 主动触发一次 */
|