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