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