@whitesev/domutils 1.6.6 → 1.6.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.
@@ -326,10 +326,8 @@ var DOMUtils = (function () {
326
326
  * 获取安全的html
327
327
  */
328
328
  getSafeHTML(text) {
329
- // @ts-ignore
330
- if (globalThis.trustedTypes) {
331
- // @ts-ignore
332
- const policy = globalThis.trustedTypes.createPolicy("safe-innerHTML", {
329
+ if (window.trustedTypes) {
330
+ const policy = window.trustedTypes.createPolicy("safe-innerHTML", {
333
331
  createHTML: (html) => html,
334
332
  });
335
333
  return policy.createHTML(text);
@@ -352,7 +350,7 @@ var DOMUtils = (function () {
352
350
  * @param element
353
351
  */
354
352
  showElement(element) {
355
- let dupNode = element.cloneNode(true);
353
+ const dupNode = element.cloneNode(true);
356
354
  dupNode.setAttribute("style", "visibility: hidden !important;display:block !important;");
357
355
  this.windowApi.document.documentElement.appendChild(dupNode);
358
356
  return {
@@ -383,7 +381,7 @@ var DOMUtils = (function () {
383
381
  }
384
382
  styles = view.getComputedStyle(element);
385
383
  }
386
- let value = parseFloat(styles[styleName]);
384
+ const value = parseFloat(styles[styleName]);
387
385
  if (isNaN(value)) {
388
386
  return 0;
389
387
  }
@@ -448,7 +446,7 @@ var DOMUtils = (function () {
448
446
  try {
449
447
  return setTimeout$1(callback, timeout);
450
448
  }
451
- catch (error) {
449
+ catch {
452
450
  return this.windowApi.setTimeout(callback, timeout);
453
451
  }
454
452
  },
@@ -461,7 +459,8 @@ var DOMUtils = (function () {
461
459
  clearTimeout$1(timeId);
462
460
  }
463
461
  }
464
- catch (error) {
462
+ catch {
463
+ // TODO
465
464
  }
466
465
  finally {
467
466
  this.windowApi.clearTimeout(timeId);
@@ -474,7 +473,7 @@ var DOMUtils = (function () {
474
473
  try {
475
474
  return setInterval$1(callback, timeout);
476
475
  }
477
- catch (error) {
476
+ catch {
478
477
  return this.windowApi.setInterval(callback, timeout);
479
478
  }
480
479
  },
@@ -487,7 +486,8 @@ var DOMUtils = (function () {
487
486
  clearInterval$1(timeId);
488
487
  }
489
488
  }
490
- catch (error) {
489
+ catch {
490
+ // TODO
491
491
  }
492
492
  finally {
493
493
  this.windowApi.clearInterval(timeId);
@@ -535,7 +535,7 @@ var DOMUtils = (function () {
535
535
  * @param option
536
536
  */
537
537
  function getOption(args, startIndex, option) {
538
- let currentParam = args[startIndex];
538
+ const currentParam = args[startIndex];
539
539
  if (typeof currentParam === "boolean") {
540
540
  option.capture = currentParam;
541
541
  if (typeof args[startIndex + 1] === "boolean") {
@@ -557,8 +557,9 @@ var DOMUtils = (function () {
557
557
  }
558
558
  return option;
559
559
  }
560
- let DOMUtilsContext = this;
561
- let args = arguments;
560
+ const DOMUtilsContext = this;
561
+ // eslint-disable-next-line prefer-rest-params
562
+ const args = arguments;
562
563
  if (typeof element === "string") {
563
564
  element = DOMUtilsContext.selectorAll(element);
564
565
  }
@@ -634,14 +635,14 @@ var DOMUtils = (function () {
634
635
  totalParent = DOMUtilsContext.windowApi.document.documentElement;
635
636
  }
636
637
  }
637
- let findValue = selectorList.find((selectorItem) => {
638
+ const findValue = selectorList.find((selectorItem) => {
638
639
  // 判断目标元素是否匹配选择器
639
640
  if (DOMUtilsContext.matches(eventTarget, selectorItem)) {
640
641
  /* 当前目标可以被selector所匹配到 */
641
642
  return true;
642
643
  }
643
644
  /* 在上层与主元素之间寻找可以被selector所匹配到的 */
644
- let $closestMatches = DOMUtilsContext.closest(eventTarget, selectorItem);
645
+ const $closestMatches = DOMUtilsContext.closest(eventTarget, selectorItem);
645
646
  if ($closestMatches && totalParent?.contains($closestMatches)) {
646
647
  eventTarget = $closestMatches;
647
648
  return true;
@@ -657,7 +658,9 @@ var DOMUtils = (function () {
657
658
  },
658
659
  });
659
660
  }
660
- catch (error) { }
661
+ catch {
662
+ // TODO
663
+ }
661
664
  listenerCallBack.call(eventTarget, event, eventTarget);
662
665
  checkOptionOnceToRemoveEventListener();
663
666
  }
@@ -672,7 +675,7 @@ var DOMUtils = (function () {
672
675
  eventTypeList.forEach((eventName) => {
673
676
  elementItem.addEventListener(eventName, domUtilsEventCallBack, listenerOption);
674
677
  /* 获取对象上的事件 */
675
- let elementEvents = Reflect.get(elementItem, DOMUtilsData.SymbolEvents) || {};
678
+ const elementEvents = Reflect.get(elementItem, DOMUtilsData.SymbolEvents) || {};
676
679
  /* 初始化对象上的xx事件 */
677
680
  elementEvents[eventName] = elementEvents[eventName] || [];
678
681
  elementEvents[eventName].push({
@@ -694,7 +697,7 @@ var DOMUtils = (function () {
694
697
  * @param option
695
698
  */
696
699
  function getOption(args1, startIndex, option) {
697
- let currentParam = args1[startIndex];
700
+ const currentParam = args1[startIndex];
698
701
  if (typeof currentParam === "boolean") {
699
702
  option.capture = currentParam;
700
703
  }
@@ -703,8 +706,9 @@ var DOMUtils = (function () {
703
706
  }
704
707
  return option;
705
708
  }
706
- let DOMUtilsContext = this;
707
- let args = arguments;
709
+ const DOMUtilsContext = this;
710
+ // eslint-disable-next-line prefer-rest-params
711
+ const args = arguments;
708
712
  if (typeof element === "string") {
709
713
  element = DOMUtilsContext.selectorAll(element);
710
714
  }
@@ -766,14 +770,14 @@ var DOMUtils = (function () {
766
770
  }
767
771
  elementList.forEach((elementItem) => {
768
772
  /* 获取对象上的事件 */
769
- let elementEvents = Reflect.get(elementItem, DOMUtilsData.SymbolEvents) || {};
773
+ const elementEvents = Reflect.get(elementItem, DOMUtilsData.SymbolEvents) || {};
770
774
  eventTypeList.forEach((eventName) => {
771
775
  let handlers = elementEvents[eventName] || [];
772
776
  if (typeof filter === "function") {
773
777
  handlers = handlers.filter(filter);
774
778
  }
775
779
  for (let index = 0; index < handlers.length; index++) {
776
- let handler = handlers[index];
780
+ const handler = handlers[index];
777
781
  let flag = true;
778
782
  if (flag && listenerCallBack && handler.originCallBack !== listenerCallBack) {
779
783
  // callback不同
@@ -808,7 +812,7 @@ var DOMUtils = (function () {
808
812
  * @param eventType (可选)需要取消监听的事件
809
813
  */
810
814
  offAll(element, eventType) {
811
- let DOMUtilsContext = this;
815
+ const DOMUtilsContext = this;
812
816
  if (typeof element === "string") {
813
817
  element = DOMUtilsContext.selectorAll(element);
814
818
  }
@@ -834,10 +838,10 @@ var DOMUtils = (function () {
834
838
  if (!symbolEvents.toString().startsWith("Symbol(events_")) {
835
839
  return;
836
840
  }
837
- let elementEvents = elementItem[symbolEvents] || {};
838
- let iterEventNameList = eventTypeList.length ? eventTypeList : Object.keys(elementEvents);
841
+ const elementEvents = elementItem[symbolEvents] || {};
842
+ const iterEventNameList = eventTypeList.length ? eventTypeList : Object.keys(elementEvents);
839
843
  iterEventNameList.forEach((eventName) => {
840
- let handlers = elementEvents[eventName];
844
+ const handlers = elementEvents[eventName];
841
845
  if (!handlers) {
842
846
  return;
843
847
  }
@@ -846,7 +850,7 @@ var DOMUtils = (function () {
846
850
  capture: handler["option"]["capture"],
847
851
  });
848
852
  }
849
- let events = Reflect.get(elementItem, symbolEvents);
853
+ const events = Reflect.get(elementItem, symbolEvents);
850
854
  DOMUtilsCommonUtils.delete(events, eventName);
851
855
  });
852
856
  });
@@ -864,7 +868,7 @@ var DOMUtils = (function () {
864
868
  if (typeof callback !== "function") {
865
869
  return;
866
870
  }
867
- let DOMUtilsContext = this;
871
+ const DOMUtilsContext = this;
868
872
  /**
869
873
  * 检测文档是否加载完毕
870
874
  */
@@ -879,7 +883,7 @@ var DOMUtils = (function () {
879
883
  return false;
880
884
  }
881
885
  }
882
- catch (error) {
886
+ catch {
883
887
  return false;
884
888
  }
885
889
  }
@@ -890,7 +894,7 @@ var DOMUtils = (function () {
890
894
  removeDomReadyListener();
891
895
  callback();
892
896
  }
893
- let targetList = [
897
+ const targetList = [
894
898
  {
895
899
  target: DOMUtilsContext.windowApi.document,
896
900
  eventType: "DOMContentLoaded",
@@ -907,7 +911,7 @@ var DOMUtils = (function () {
907
911
  */
908
912
  function addDomReadyListener() {
909
913
  for (let index = 0; index < targetList.length; index++) {
910
- let item = targetList[index];
914
+ const item = targetList[index];
911
915
  item.target.addEventListener(item.eventType, item.callback);
912
916
  }
913
917
  }
@@ -916,7 +920,7 @@ var DOMUtils = (function () {
916
920
  */
917
921
  function removeDomReadyListener() {
918
922
  for (let index = 0; index < targetList.length; index++) {
919
- let item = targetList[index];
923
+ const item = targetList[index];
920
924
  item.target.removeEventListener(item.eventType, item.callback);
921
925
  }
922
926
  }
@@ -944,7 +948,7 @@ var DOMUtils = (function () {
944
948
  * DOMUtils.trigger("a.xx",["click","tap","hover"])
945
949
  */
946
950
  trigger(element, eventType, details, useDispatchToTriggerEvent = true) {
947
- let DOMUtilsContext = this;
951
+ const DOMUtilsContext = this;
948
952
  if (typeof element === "string") {
949
953
  element = DOMUtilsContext.selectorAll(element);
950
954
  }
@@ -968,7 +972,7 @@ var DOMUtils = (function () {
968
972
  }
969
973
  elementList.forEach((elementItem) => {
970
974
  /* 获取对象上的事件 */
971
- let events = elementItem[DOMUtilsData.SymbolEvents] || {};
975
+ const events = elementItem[DOMUtilsData.SymbolEvents] || {};
972
976
  eventTypeList.forEach((_eventType_) => {
973
977
  let event = null;
974
978
  if (details && details instanceof Event) {
@@ -1008,7 +1012,7 @@ var DOMUtils = (function () {
1008
1012
  * })
1009
1013
  * */
1010
1014
  click(element, handler, details, useDispatchToTriggerEvent) {
1011
- let DOMUtilsContext = this;
1015
+ const DOMUtilsContext = this;
1012
1016
  if (typeof element === "string") {
1013
1017
  element = DOMUtilsContext.selectorAll(element);
1014
1018
  }
@@ -1044,7 +1048,7 @@ var DOMUtils = (function () {
1044
1048
  * })
1045
1049
  * */
1046
1050
  blur(element, handler, details, useDispatchToTriggerEvent) {
1047
- let DOMUtilsContext = this;
1051
+ const DOMUtilsContext = this;
1048
1052
  if (typeof element === "string") {
1049
1053
  element = DOMUtilsContext.selectorAll(element);
1050
1054
  }
@@ -1080,7 +1084,7 @@ var DOMUtils = (function () {
1080
1084
  * })
1081
1085
  * */
1082
1086
  focus(element, handler, details, useDispatchToTriggerEvent) {
1083
- let DOMUtilsContext = this;
1087
+ const DOMUtilsContext = this;
1084
1088
  if (typeof element === "string") {
1085
1089
  element = DOMUtilsContext.selectorAll(element);
1086
1090
  }
@@ -1116,7 +1120,7 @@ var DOMUtils = (function () {
1116
1120
  * })
1117
1121
  */
1118
1122
  hover(element, handler, option) {
1119
- let DOMUtilsContext = this;
1123
+ const DOMUtilsContext = this;
1120
1124
  if (typeof element === "string") {
1121
1125
  element = DOMUtilsContext.selectorAll(element);
1122
1126
  }
@@ -1140,7 +1144,7 @@ var DOMUtils = (function () {
1140
1144
  * @param option 配置项,这里默认配置once为true
1141
1145
  */
1142
1146
  animationend(element, handler, option) {
1143
- let DOMUtilsContext = this;
1147
+ const DOMUtilsContext = this;
1144
1148
  if (typeof element === "string") {
1145
1149
  element = DOMUtilsContext.selector(element);
1146
1150
  }
@@ -1175,7 +1179,7 @@ var DOMUtils = (function () {
1175
1179
  * @param option 配置项,这里默认配置once为true
1176
1180
  */
1177
1181
  transitionend(element, handler, option) {
1178
- let DOMUtilsContext = this;
1182
+ const DOMUtilsContext = this;
1179
1183
  if (typeof element === "string") {
1180
1184
  element = DOMUtilsContext.selector(element);
1181
1185
  }
@@ -1219,7 +1223,7 @@ var DOMUtils = (function () {
1219
1223
  * })
1220
1224
  */
1221
1225
  keyup(element, handler, option) {
1222
- let DOMUtilsContext = this;
1226
+ const DOMUtilsContext = this;
1223
1227
  if (element == null) {
1224
1228
  return;
1225
1229
  }
@@ -1251,7 +1255,7 @@ var DOMUtils = (function () {
1251
1255
  * })
1252
1256
  */
1253
1257
  keydown(element, handler, option) {
1254
- let DOMUtilsContext = this;
1258
+ const DOMUtilsContext = this;
1255
1259
  if (element == null) {
1256
1260
  return;
1257
1261
  }
@@ -1283,7 +1287,7 @@ var DOMUtils = (function () {
1283
1287
  * })
1284
1288
  */
1285
1289
  keypress(element, handler, option) {
1286
- let DOMUtilsContext = this;
1290
+ const DOMUtilsContext = this;
1287
1291
  if (element == null) {
1288
1292
  return;
1289
1293
  }
@@ -1300,80 +1304,80 @@ var DOMUtils = (function () {
1300
1304
  DOMUtilsContext.on(element, "keypress", null, handler, option);
1301
1305
  }
1302
1306
  /**
1303
- * 监听某个元素键盘按键事件或window全局按键事件
1304
- * 按下有值的键时触发,按下Ctrl\Alt\Shift\Meta是无值键。按下先触发keydown事件,再触发keypress事件。
1305
- * @param element 需要监听的对象,可以是全局Window或者某个元素
1306
- * @param eventName 事件名,默认keypress
1307
- * @param callback 自己定义的回调事件,参数1为当前的key,参数2为组合按键,数组类型,包含ctrl、shift、alt和meta(win键或mac的cmd键)
1308
- * @param options 监听事件的配置
1309
- * @example
1310
- Utils.listenKeyboard(window,(keyName,keyValue,otherKey,event)=>{
1311
- if(keyName === "Enter"){
1312
- console.log("回车按键的值是:"+keyValue)
1313
- }
1314
- if(otherKey.indexOf("ctrl") && keyName === "Enter" ){
1315
- console.log("Ctrl和回车键");
1316
- }
1317
- })
1318
- * @example
1319
- 字母和数字键的键码值(keyCode)
1320
- 按键 键码 按键 键码 按键 键码 按键 键码
1321
- A 65 J 74 S 83 1 49
1322
- B 66 K 75 T 84 2 50
1323
- C 67 L 76 U 85 3 51
1324
- D 68 M 77 V 86 4 52
1325
- E 69 N 78 W 87 5 53
1326
- F 70 O 79 X 88 6 54
1327
- G 71 P 80 Y 89 7 55
1328
- H 72 Q 81 Z 90 8 56
1329
- I 73 R 82 0 48 9 57
1330
-
1331
- 数字键盘上的键的键码值(keyCode)
1332
- 功能键键码值(keyCode)
1333
- 按键 键码 按键 键码 按键 键码 按键 键码
1334
- 0 96 8 104 F1 112 F7 118
1335
- 1 97 9 105 F2 113 F8 119
1336
- 2 98 * 106 F3 114 F9 120
1337
- 3 99 + 107 F4 115 F10 121
1338
- 4 100 Enter 108 F5 116 F11 122
1339
- 5 101 - 109 F6 117 F12 123
1340
- 6 102 . 110
1341
- 7 103 / 111
1342
-
1343
- 控制键键码值(keyCode)
1344
- 按键 键码 按键 键码 按键 键码 按键 键码
1345
- BackSpace 8 Esc 27 → 39 -_ 189
1346
- Tab 9 Spacebar 32 ↓ 40 .> 190
1347
- Clear 12 Page Up 33 Insert 45 /? 191
1348
- Enter 13 Page Down 34 Delete 46 `~ 192
1349
- Shift 16 End 35 Num Lock 144 [{ 219
1350
- Control 17 Home 36 ;: 186 \| 220
1351
- Alt 18 ← 37 =+ 187 ]} 221
1352
- Cape Lock 20 ↑ 38 ,< 188 '" 222
1353
-
1354
- 多媒体键码值(keyCode)
1355
- 按键 键码
1356
- 音量加 175
1357
- 音量减 174
1358
- 停止 179
1359
- 静音 173
1360
- 浏览器 172
1361
- 邮件 180
1362
- 搜索 170
1363
- 收藏 171
1364
- **/
1307
+ * 监听某个元素键盘按键事件或window全局按键事件
1308
+ * 按下有值的键时触发,按下Ctrl\Alt\Shift\Meta是无值键。按下先触发keydown事件,再触发keypress事件。
1309
+ * @param element 需要监听的对象,可以是全局Window或者某个元素
1310
+ * @param eventName 事件名,默认keypress
1311
+ * @param callback 自己定义的回调事件,参数1为当前的key,参数2为组合按键,数组类型,包含ctrl、shift、alt和meta(win键或mac的cmd键)
1312
+ * @param options 监听事件的配置
1313
+ * @example
1314
+ Utils.listenKeyboard(window,(keyName,keyValue,otherKey,event)=>{
1315
+ if(keyName === "Enter"){
1316
+ console.log("回车按键的值是:"+keyValue)
1317
+ }
1318
+ if(otherKey.indexOf("ctrl") && keyName === "Enter" ){
1319
+ console.log("Ctrl和回车键");
1320
+ }
1321
+ })
1322
+ * @example
1323
+ 字母和数字键的键码值(keyCode)
1324
+ 按键 键码 按键 键码 按键 键码 按键 键码
1325
+ A 65 J 74 S 83 1 49
1326
+ B 66 K 75 T 84 2 50
1327
+ C 67 L 76 U 85 3 51
1328
+ D 68 M 77 V 86 4 52
1329
+ E 69 N 78 W 87 5 53
1330
+ F 70 O 79 X 88 6 54
1331
+ G 71 P 80 Y 89 7 55
1332
+ H 72 Q 81 Z 90 8 56
1333
+ I 73 R 82 0 48 9 57
1334
+
1335
+ 数字键盘上的键的键码值(keyCode)
1336
+ 功能键键码值(keyCode)
1337
+ 按键 键码 按键 键码 按键 键码 按键 键码
1338
+ 0 96 8 104 F1 112 F7 118
1339
+ 1 97 9 105 F2 113 F8 119
1340
+ 2 98 * 106 F3 114 F9 120
1341
+ 3 99 + 107 F4 115 F10 121
1342
+ 4 100 Enter 108 F5 116 F11 122
1343
+ 5 101 - 109 F6 117 F12 123
1344
+ 6 102 . 110
1345
+ 7 103 / 111
1346
+
1347
+ 控制键键码值(keyCode)
1348
+ 按键 键码 按键 键码 按键 键码 按键 键码
1349
+ BackSpace 8 Esc 27 → 39 -_ 189
1350
+ Tab 9 Spacebar 32 ↓ 40 .> 190
1351
+ Clear 12 Page Up 33 Insert 45 /? 191
1352
+ Enter 13 Page Down 34 Delete 46 `~ 192
1353
+ Shift 16 End 35 Num Lock 144 [{ 219
1354
+ Control 17 Home 36 ;: 186 \| 220
1355
+ Alt 18 ← 37 =+ 187 ]} 221
1356
+ Cape Lock 20 ↑ 38 ,< 188 '" 222
1357
+
1358
+ 多媒体键码值(keyCode)
1359
+ 按键 键码
1360
+ 音量加 175
1361
+ 音量减 174
1362
+ 停止 179
1363
+ 静音 173
1364
+ 浏览器 172
1365
+ 邮件 180
1366
+ 搜索 170
1367
+ 收藏 171
1368
+ **/
1365
1369
  listenKeyboard(element, eventName = "keypress", callback, options) {
1366
- let DOMUtilsContext = this;
1370
+ const DOMUtilsContext = this;
1367
1371
  if (typeof element === "string") {
1368
1372
  element = DOMUtilsContext.selectorAll(element);
1369
1373
  }
1370
- let keyboardEventCallBack = function (event) {
1374
+ const keyboardEventCallBack = function (event) {
1371
1375
  /** 键名 */
1372
- let keyName = event.key || event.code;
1376
+ const keyName = event.key || event.code;
1373
1377
  /** 键值 */
1374
- let keyValue = event.charCode || event.keyCode || event.which;
1378
+ const keyValue = event.charCode || event.keyCode || event.which;
1375
1379
  /** 组合键列表 */
1376
- let otherCodeList = [];
1380
+ const otherCodeList = [];
1377
1381
  if (event.ctrlKey) {
1378
1382
  otherCodeList.push("ctrl");
1379
1383
  }
@@ -1411,29 +1415,27 @@ var DOMUtils = (function () {
1411
1415
  return $ele?.innerHTML?.trim() === "";
1412
1416
  });
1413
1417
  }
1414
- else if (selector.match(/[^\s]{1}:contains\("(.*)"\)$/i) ||
1415
- selector.match(/[^\s]{1}:contains\('(.*)'\)$/i)) {
1418
+ else if (selector.match(/[^\s]{1}:contains\("(.*)"\)$/i) || selector.match(/[^\s]{1}:contains\('(.*)'\)$/i)) {
1416
1419
  // contains 语法
1417
- let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
1418
- let text = textMatch[2];
1420
+ const textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
1421
+ const text = textMatch[2];
1419
1422
  selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
1420
1423
  return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
1421
1424
  // @ts-ignore
1422
1425
  return ($ele?.textContent || $ele?.innerText)?.includes(text);
1423
1426
  });
1424
1427
  }
1425
- else if (selector.match(/[^\s]{1}:regexp\("(.*)"\)$/i) ||
1426
- selector.match(/[^\s]{1}:regexp\('(.*)'\)$/i)) {
1428
+ else if (selector.match(/[^\s]{1}:regexp\("(.*)"\)$/i) || selector.match(/[^\s]{1}:regexp\('(.*)'\)$/i)) {
1427
1429
  // regexp 语法
1428
- let textMatch = selector.match(/:regexp\(("|')(.*)("|')\)$/i);
1430
+ const textMatch = selector.match(/:regexp\(("|')(.*)("|')\)$/i);
1429
1431
  let pattern = textMatch[2];
1430
- let flagMatch = pattern.match(/("|'),[\s]*("|')([igm]{0,3})$/i);
1432
+ const flagMatch = pattern.match(/("|'),[\s]*("|')([igm]{0,3})$/i);
1431
1433
  let flags = "";
1432
1434
  if (flagMatch) {
1433
1435
  pattern = pattern.replace(/("|'),[\s]*("|')([igm]{0,3})$/gi, "");
1434
1436
  flags = flagMatch[3];
1435
1437
  }
1436
- let regexp = new RegExp(pattern, flags);
1438
+ const regexp = new RegExp(pattern, flags);
1437
1439
  selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
1438
1440
  return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
1439
1441
  // @ts-ignore
@@ -1476,11 +1478,10 @@ var DOMUtils = (function () {
1476
1478
  selector = selector.replace(/:empty$/gi, "");
1477
1479
  return $el.matches(selector) && $el?.innerHTML?.trim() === "";
1478
1480
  }
1479
- else if (selector.match(/[^\s]{1}:contains\("(.*)"\)$/i) ||
1480
- selector.match(/[^\s]{1}:contains\('(.*)'\)$/i)) {
1481
+ else if (selector.match(/[^\s]{1}:contains\("(.*)"\)$/i) || selector.match(/[^\s]{1}:contains\('(.*)'\)$/i)) {
1481
1482
  // contains 语法
1482
- let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
1483
- let text = textMatch[2];
1483
+ const textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
1484
+ const text = textMatch[2];
1484
1485
  selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
1485
1486
  // @ts-ignore
1486
1487
  let content = $el?.textContent || $el?.innerText;
@@ -1489,18 +1490,17 @@ var DOMUtils = (function () {
1489
1490
  }
1490
1491
  return $el.matches(selector) && content?.includes(text);
1491
1492
  }
1492
- else if (selector.match(/[^\s]{1}:regexp\("(.*)"\)$/i) ||
1493
- selector.match(/[^\s]{1}:regexp\('(.*)'\)$/i)) {
1493
+ else if (selector.match(/[^\s]{1}:regexp\("(.*)"\)$/i) || selector.match(/[^\s]{1}:regexp\('(.*)'\)$/i)) {
1494
1494
  // regexp 语法
1495
- let textMatch = selector.match(/:regexp\(("|')(.*)("|')\)$/i);
1495
+ const textMatch = selector.match(/:regexp\(("|')(.*)("|')\)$/i);
1496
1496
  let pattern = textMatch[2];
1497
- let flagMatch = pattern.match(/("|'),[\s]*("|')([igm]{0,3})$/i);
1497
+ const flagMatch = pattern.match(/("|'),[\s]*("|')([igm]{0,3})$/i);
1498
1498
  let flags = "";
1499
1499
  if (flagMatch) {
1500
1500
  pattern = pattern.replace(/("|'),[\s]*("|')([igm]{0,3})$/gi, "");
1501
1501
  flags = flagMatch[3];
1502
1502
  }
1503
- let regexp = new RegExp(pattern, flags);
1503
+ const regexp = new RegExp(pattern, flags);
1504
1504
  selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
1505
1505
  // @ts-ignore
1506
1506
  let content = $el?.textContent || $el?.innerText;
@@ -1519,45 +1519,43 @@ var DOMUtils = (function () {
1519
1519
  if (selector.match(/[^\s]{1}:empty$/gi)) {
1520
1520
  // empty 语法
1521
1521
  selector = selector.replace(/:empty$/gi, "");
1522
- let $closest = $el?.closest(selector);
1522
+ const $closest = $el?.closest(selector);
1523
1523
  if ($closest && $closest?.innerHTML?.trim() === "") {
1524
1524
  return $closest;
1525
1525
  }
1526
1526
  return null;
1527
1527
  }
1528
- else if (selector.match(/[^\s]{1}:contains\("(.*)"\)$/i) ||
1529
- selector.match(/[^\s]{1}:contains\('(.*)'\)$/i)) {
1528
+ else if (selector.match(/[^\s]{1}:contains\("(.*)"\)$/i) || selector.match(/[^\s]{1}:contains\('(.*)'\)$/i)) {
1530
1529
  // contains 语法
1531
- let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
1532
- let text = textMatch[2];
1530
+ const textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
1531
+ const text = textMatch[2];
1533
1532
  selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
1534
- let $closest = $el?.closest(selector);
1533
+ const $closest = $el?.closest(selector);
1535
1534
  if ($closest) {
1536
1535
  // @ts-ignore
1537
- let content = $el?.textContent || $el?.innerText;
1536
+ const content = $el?.textContent || $el?.innerText;
1538
1537
  if (typeof content === "string" && content.includes(text)) {
1539
1538
  return $closest;
1540
1539
  }
1541
1540
  }
1542
1541
  return null;
1543
1542
  }
1544
- else if (selector.match(/[^\s]{1}:regexp\("(.*)"\)$/i) ||
1545
- selector.match(/[^\s]{1}:regexp\('(.*)'\)$/i)) {
1543
+ else if (selector.match(/[^\s]{1}:regexp\("(.*)"\)$/i) || selector.match(/[^\s]{1}:regexp\('(.*)'\)$/i)) {
1546
1544
  // regexp 语法
1547
- let textMatch = selector.match(/:regexp\(("|')(.*)("|')\)$/i);
1545
+ const textMatch = selector.match(/:regexp\(("|')(.*)("|')\)$/i);
1548
1546
  let pattern = textMatch[2];
1549
- let flagMatch = pattern.match(/("|'),[\s]*("|')([igm]{0,3})$/i);
1547
+ const flagMatch = pattern.match(/("|'),[\s]*("|')([igm]{0,3})$/i);
1550
1548
  let flags = "";
1551
1549
  if (flagMatch) {
1552
1550
  pattern = pattern.replace(/("|'),[\s]*("|')([igm]{0,3})$/gi, "");
1553
1551
  flags = flagMatch[3];
1554
1552
  }
1555
- let regexp = new RegExp(pattern, flags);
1553
+ const regexp = new RegExp(pattern, flags);
1556
1554
  selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
1557
- let $closest = $el?.closest(selector);
1555
+ const $closest = $el?.closest(selector);
1558
1556
  if ($closest) {
1559
1557
  // @ts-ignore
1560
- let content = $el?.textContent || $el?.innerText;
1558
+ const content = $el?.textContent || $el?.innerText;
1561
1559
  if (typeof content === "string" && content.match(regexp)) {
1562
1560
  return $closest;
1563
1561
  }
@@ -1566,20 +1564,22 @@ var DOMUtils = (function () {
1566
1564
  }
1567
1565
  else {
1568
1566
  // 普通语法
1569
- let $closest = $el?.closest(selector);
1567
+ const $closest = $el?.closest(selector);
1570
1568
  return $closest;
1571
1569
  }
1572
1570
  }
1573
1571
  }
1574
1572
 
1573
+ const version = "1.6.6";
1574
+
1575
1575
  class DOMUtils extends DOMUtilsEvent {
1576
1576
  constructor(option) {
1577
1577
  super(option);
1578
1578
  }
1579
1579
  /** 版本号 */
1580
- version = "2025.8.11";
1580
+ version = version;
1581
1581
  attr(element, attrName, attrValue) {
1582
- let DOMUtilsContext = this;
1582
+ const DOMUtilsContext = this;
1583
1583
  if (typeof element === "string") {
1584
1584
  element = DOMUtilsContext.selectorAll(element);
1585
1585
  }
@@ -1613,8 +1613,8 @@ var DOMUtils = (function () {
1613
1613
  property,
1614
1614
  /** 自定义属性 */
1615
1615
  attributes) {
1616
- let DOMUtilsContext = this;
1617
- let tempElement = DOMUtilsContext.windowApi.document.createElement(tagName);
1616
+ const DOMUtilsContext = this;
1617
+ const tempElement = DOMUtilsContext.windowApi.document.createElement(tagName);
1618
1618
  if (typeof property === "string") {
1619
1619
  DOMUtilsContext.html(tempElement, property);
1620
1620
  return tempElement;
@@ -1626,7 +1626,7 @@ var DOMUtils = (function () {
1626
1626
  attributes = {};
1627
1627
  }
1628
1628
  Object.keys(property).forEach((key) => {
1629
- let value = property[key];
1629
+ const value = property[key];
1630
1630
  if (key === "innerHTML") {
1631
1631
  DOMUtilsContext.html(tempElement, value);
1632
1632
  return;
@@ -1648,18 +1648,16 @@ var DOMUtils = (function () {
1648
1648
  return tempElement;
1649
1649
  }
1650
1650
  css(element, property, value) {
1651
- let DOMUtilsContext = this;
1651
+ const DOMUtilsContext = this;
1652
1652
  /**
1653
1653
  * 把纯数字没有px的加上
1654
1654
  */
1655
1655
  function handlePixe(propertyName, propertyValue) {
1656
- let allowAddPixe = ["width", "height", "top", "left", "right", "bottom", "font-size"];
1656
+ const allowAddPixe = ["width", "height", "top", "left", "right", "bottom", "font-size"];
1657
1657
  if (typeof propertyValue === "number") {
1658
1658
  propertyValue = propertyValue.toString();
1659
1659
  }
1660
- if (typeof propertyValue === "string" &&
1661
- allowAddPixe.includes(propertyName) &&
1662
- propertyValue.match(/[0-9]$/gi)) {
1660
+ if (typeof propertyValue === "string" && allowAddPixe.includes(propertyName) && propertyValue.match(/[0-9]$/gi)) {
1663
1661
  propertyValue = propertyValue + "px";
1664
1662
  }
1665
1663
  return propertyValue;
@@ -1691,10 +1689,9 @@ var DOMUtils = (function () {
1691
1689
  });
1692
1690
  return;
1693
1691
  }
1694
- else ;
1695
1692
  return;
1696
1693
  }
1697
- let setStyleProperty = (propertyName, propertyValue) => {
1694
+ const setStyleProperty = (propertyName, propertyValue) => {
1698
1695
  if (typeof propertyValue === "string" && propertyValue.trim().endsWith("!important")) {
1699
1696
  propertyValue = propertyValue
1700
1697
  .trim()
@@ -1716,8 +1713,8 @@ var DOMUtils = (function () {
1716
1713
  }
1717
1714
  }
1718
1715
  else if (typeof property === "object") {
1719
- for (let prop in property) {
1720
- let value = property[prop];
1716
+ for (const prop in property) {
1717
+ const value = property[prop];
1721
1718
  setStyleProperty(prop, value);
1722
1719
  }
1723
1720
  }
@@ -1727,7 +1724,7 @@ var DOMUtils = (function () {
1727
1724
  }
1728
1725
  }
1729
1726
  text(element, text) {
1730
- let DOMUtilsContext = this;
1727
+ const DOMUtilsContext = this;
1731
1728
  if (typeof element === "string") {
1732
1729
  element = DOMUtilsContext.selectorAll(element);
1733
1730
  }
@@ -1763,7 +1760,7 @@ var DOMUtils = (function () {
1763
1760
  }
1764
1761
  }
1765
1762
  html(element, html) {
1766
- let DOMUtilsContext = this;
1763
+ const DOMUtilsContext = this;
1767
1764
  if (typeof element === "string") {
1768
1765
  element = DOMUtilsContext.selectorAll(element);
1769
1766
  }
@@ -1801,19 +1798,19 @@ var DOMUtils = (function () {
1801
1798
  * 获取移动元素的transform偏移
1802
1799
  */
1803
1800
  getTransform(element, isShow = false) {
1804
- let DOMUtilsContext = this;
1801
+ const DOMUtilsContext = this;
1805
1802
  let transform_left = 0;
1806
1803
  let transform_top = 0;
1807
1804
  if (!(isShow || (!isShow && DOMUtilsCommonUtils.isShow(element)))) {
1808
1805
  /* 未显示 */
1809
- let { recovery } = DOMUtilsCommonUtils.showElement(element);
1810
- let transformInfo = DOMUtilsContext.getTransform(element, true);
1806
+ const { recovery } = DOMUtilsCommonUtils.showElement(element);
1807
+ const transformInfo = DOMUtilsContext.getTransform(element, true);
1811
1808
  recovery();
1812
1809
  return transformInfo;
1813
1810
  }
1814
- let elementTransform = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).transform;
1811
+ const elementTransform = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).transform;
1815
1812
  if (elementTransform != null && elementTransform !== "none" && elementTransform !== "") {
1816
- let elementTransformSplit = elementTransform.match(/\((.+)\)/)?.[1].split(",");
1813
+ const elementTransformSplit = elementTransform.match(/\((.+)\)/)?.[1].split(",");
1817
1814
  if (elementTransformSplit) {
1818
1815
  transform_left = Math.abs(parseInt(elementTransformSplit[4]));
1819
1816
  transform_top = Math.abs(parseInt(elementTransformSplit[5]));
@@ -1829,7 +1826,7 @@ var DOMUtils = (function () {
1829
1826
  };
1830
1827
  }
1831
1828
  val(element, value) {
1832
- let DOMUtilsContext = this;
1829
+ const DOMUtilsContext = this;
1833
1830
  if (typeof element === "string") {
1834
1831
  element = DOMUtilsContext.selectorAll(element);
1835
1832
  }
@@ -1869,7 +1866,7 @@ var DOMUtils = (function () {
1869
1866
  }
1870
1867
  }
1871
1868
  prop(element, propName, propValue) {
1872
- let DOMUtilsContext = this;
1869
+ const DOMUtilsContext = this;
1873
1870
  if (typeof element === "string") {
1874
1871
  element = DOMUtilsContext.selectorAll(element);
1875
1872
  }
@@ -1911,7 +1908,7 @@ var DOMUtils = (function () {
1911
1908
  * DOMUtils.removeAttr("a.xx","data-value")
1912
1909
  * */
1913
1910
  removeAttr(element, attrName) {
1914
- let DOMUtilsContext = this;
1911
+ const DOMUtilsContext = this;
1915
1912
  if (typeof element === "string") {
1916
1913
  element = DOMUtilsContext.selectorAll(element);
1917
1914
  }
@@ -1937,7 +1934,7 @@ var DOMUtils = (function () {
1937
1934
  * DOMUtils.removeClass("a.xx","xx")
1938
1935
  */
1939
1936
  removeClass(element, className) {
1940
- let DOMUtilsContext = this;
1937
+ const DOMUtilsContext = this;
1941
1938
  if (typeof element === "string") {
1942
1939
  element = DOMUtilsContext.selectorAll(element);
1943
1940
  }
@@ -1974,7 +1971,7 @@ var DOMUtils = (function () {
1974
1971
  * DOMUtils.removeProp("a.xx","href")
1975
1972
  * */
1976
1973
  removeProp(element, propName) {
1977
- let DOMUtilsContext = this;
1974
+ const DOMUtilsContext = this;
1978
1975
  if (typeof element === "string") {
1979
1976
  element = DOMUtilsContext.selectorAll(element);
1980
1977
  }
@@ -2000,7 +1997,7 @@ var DOMUtils = (function () {
2000
1997
  * DOMUtils.replaceWith("a.xx",'<b class="xx"></b>')
2001
1998
  */
2002
1999
  replaceWith(element, newElement) {
2003
- let DOMUtilsContext = this;
2000
+ const DOMUtilsContext = this;
2004
2001
  if (typeof element === "string") {
2005
2002
  element = DOMUtilsContext.selectorAll(element);
2006
2003
  }
@@ -2017,7 +2014,7 @@ var DOMUtils = (function () {
2017
2014
  if (typeof newElement === "string") {
2018
2015
  newElement = DOMUtilsContext.parseHTML(newElement, false, false);
2019
2016
  }
2020
- let $parent = element.parentElement;
2017
+ const $parent = element.parentElement;
2021
2018
  if ($parent) {
2022
2019
  $parent.replaceChild(newElement, element);
2023
2020
  }
@@ -2036,7 +2033,7 @@ var DOMUtils = (function () {
2036
2033
  * DOMUtils.addClass("a.xx","_vue_")
2037
2034
  * */
2038
2035
  addClass(element, className) {
2039
- let DOMUtilsContext = this;
2036
+ const DOMUtilsContext = this;
2040
2037
  if (typeof element === "string") {
2041
2038
  element = DOMUtilsContext.selectorAll(element);
2042
2039
  }
@@ -2066,7 +2063,7 @@ var DOMUtils = (function () {
2066
2063
  * @param className
2067
2064
  */
2068
2065
  hasClass(element, className) {
2069
- let DOMUtilsContext = this;
2066
+ const DOMUtilsContext = this;
2070
2067
  if (typeof element === "string") {
2071
2068
  element = DOMUtilsContext.selectorAll(element);
2072
2069
  }
@@ -2105,7 +2102,7 @@ var DOMUtils = (function () {
2105
2102
  * DOMUtils.append("a.xx","'<b class="xx"></b>")
2106
2103
  * */
2107
2104
  append(element, content) {
2108
- let DOMUtilsContext = this;
2105
+ const DOMUtilsContext = this;
2109
2106
  if (typeof element === "string") {
2110
2107
  element = DOMUtilsContext.selectorAll(element);
2111
2108
  }
@@ -2137,7 +2134,7 @@ var DOMUtils = (function () {
2137
2134
  }
2138
2135
  if (Array.isArray(content) || content instanceof NodeList) {
2139
2136
  /* 数组 */
2140
- let fragment = DOMUtilsContext.windowApi.document.createDocumentFragment();
2137
+ const fragment = DOMUtilsContext.windowApi.document.createDocumentFragment();
2141
2138
  content.forEach((ele) => {
2142
2139
  if (typeof ele === "string") {
2143
2140
  // 转为元素
@@ -2161,7 +2158,7 @@ var DOMUtils = (function () {
2161
2158
  * DOMUtils.prepend("a.xx","'<b class="xx"></b>")
2162
2159
  * */
2163
2160
  prepend(element, content) {
2164
- let DOMUtilsContext = this;
2161
+ const DOMUtilsContext = this;
2165
2162
  if (typeof element === "string") {
2166
2163
  element = DOMUtilsContext.selectorAll(element);
2167
2164
  }
@@ -2185,7 +2182,7 @@ var DOMUtils = (function () {
2185
2182
  }
2186
2183
  }
2187
2184
  else {
2188
- let $firstChild = element.firstChild;
2185
+ const $firstChild = element.firstChild;
2189
2186
  if ($firstChild == null) {
2190
2187
  element.prepend(content);
2191
2188
  }
@@ -2204,7 +2201,7 @@ var DOMUtils = (function () {
2204
2201
  * DOMUtils.after("a.xx","'<b class="xx"></b>")
2205
2202
  * */
2206
2203
  after(element, content) {
2207
- let DOMUtilsContext = this;
2204
+ const DOMUtilsContext = this;
2208
2205
  if (typeof element === "string") {
2209
2206
  element = DOMUtilsContext.selectorAll(element);
2210
2207
  }
@@ -2222,8 +2219,8 @@ var DOMUtils = (function () {
2222
2219
  element.insertAdjacentHTML("afterend", DOMUtilsCommonUtils.getSafeHTML(content));
2223
2220
  }
2224
2221
  else {
2225
- let $parent = element.parentElement;
2226
- let $nextSlibling = element.nextSibling;
2222
+ const $parent = element.parentElement;
2223
+ const $nextSlibling = element.nextSibling;
2227
2224
  if (!$parent || $nextSlibling) {
2228
2225
  // 任意一个不行
2229
2226
  element.after(content);
@@ -2243,7 +2240,7 @@ var DOMUtils = (function () {
2243
2240
  * DOMUtils.before("a.xx","'<b class="xx"></b>")
2244
2241
  * */
2245
2242
  before(element, content) {
2246
- let DOMUtilsContext = this;
2243
+ const DOMUtilsContext = this;
2247
2244
  if (typeof element === "string") {
2248
2245
  element = DOMUtilsContext.selectorAll(element);
2249
2246
  }
@@ -2261,7 +2258,7 @@ var DOMUtils = (function () {
2261
2258
  element.insertAdjacentHTML("beforebegin", DOMUtilsCommonUtils.getSafeHTML(content));
2262
2259
  }
2263
2260
  else {
2264
- let $parent = element.parentElement;
2261
+ const $parent = element.parentElement;
2265
2262
  if (!$parent) {
2266
2263
  element.before(content);
2267
2264
  }
@@ -2280,7 +2277,7 @@ var DOMUtils = (function () {
2280
2277
  * DOMUtils.remove("a.xx")
2281
2278
  * */
2282
2279
  remove(element) {
2283
- let DOMUtilsContext = this;
2280
+ const DOMUtilsContext = this;
2284
2281
  if (typeof element === "string") {
2285
2282
  element = DOMUtilsContext.selectorAll(element);
2286
2283
  }
@@ -2312,7 +2309,7 @@ var DOMUtils = (function () {
2312
2309
  * DOMUtils.empty("a.xx")
2313
2310
  * */
2314
2311
  empty(element) {
2315
- let DOMUtilsContext = this;
2312
+ const DOMUtilsContext = this;
2316
2313
  if (typeof element === "string") {
2317
2314
  element = DOMUtilsContext.selectorAll(element);
2318
2315
  }
@@ -2343,14 +2340,14 @@ var DOMUtils = (function () {
2343
2340
  * > 0
2344
2341
  */
2345
2342
  offset(element) {
2346
- let DOMUtilsContext = this;
2343
+ const DOMUtilsContext = this;
2347
2344
  if (typeof element === "string") {
2348
2345
  element = DOMUtilsContext.selector(element);
2349
2346
  }
2350
2347
  if (element == null) {
2351
2348
  return;
2352
2349
  }
2353
- let rect = element.getBoundingClientRect();
2350
+ const rect = element.getBoundingClientRect();
2354
2351
  return {
2355
2352
  /** y轴偏移 */
2356
2353
  top: rect.top + DOMUtilsContext.windowApi.globalThis.scrollY,
@@ -2359,14 +2356,10 @@ var DOMUtils = (function () {
2359
2356
  };
2360
2357
  }
2361
2358
  width(element, isShow = false) {
2362
- let DOMUtilsContext = this;
2359
+ const DOMUtilsContext = this;
2363
2360
  if (typeof element === "string") {
2364
2361
  element = DOMUtilsContext.selector(element);
2365
2362
  }
2366
- if (element == null) {
2367
- // @ts-ignore
2368
- return;
2369
- }
2370
2363
  if (DOMUtilsCommonUtils.isWin(element)) {
2371
2364
  return DOMUtilsContext.windowApi.window.document.documentElement.clientWidth;
2372
2365
  }
@@ -2385,11 +2378,11 @@ var DOMUtils = (function () {
2385
2378
  }
2386
2379
  /* 如果从css里获取到的值不是大于0 可能是auto 则通过offsetWidth来进行计算 */
2387
2380
  if (element.offsetWidth > 0) {
2388
- let borderLeftWidth = DOMUtilsCommonUtils.getStyleValue(element, "borderLeftWidth");
2389
- let borderRightWidth = DOMUtilsCommonUtils.getStyleValue(element, "borderRightWidth");
2390
- let paddingLeft = DOMUtilsCommonUtils.getStyleValue(element, "paddingLeft");
2391
- let paddingRight = DOMUtilsCommonUtils.getStyleValue(element, "paddingRight");
2392
- let backHeight = parseFloat(element.offsetWidth.toString()) -
2381
+ const borderLeftWidth = DOMUtilsCommonUtils.getStyleValue(element, "borderLeftWidth");
2382
+ const borderRightWidth = DOMUtilsCommonUtils.getStyleValue(element, "borderRightWidth");
2383
+ const paddingLeft = DOMUtilsCommonUtils.getStyleValue(element, "paddingLeft");
2384
+ const paddingRight = DOMUtilsCommonUtils.getStyleValue(element, "paddingRight");
2385
+ const backHeight = parseFloat(element.offsetWidth.toString()) -
2393
2386
  parseFloat(borderLeftWidth.toString()) -
2394
2387
  parseFloat(borderRightWidth.toString()) -
2395
2388
  parseFloat(paddingLeft.toString()) -
@@ -2401,24 +2394,20 @@ var DOMUtils = (function () {
2401
2394
  else {
2402
2395
  /* 未显示 */
2403
2396
  element = element;
2404
- let { recovery } = DOMUtilsCommonUtils.showElement(element);
2405
- let width = DOMUtilsContext.width(element, true);
2397
+ const { recovery } = DOMUtilsCommonUtils.showElement(element);
2398
+ const width = DOMUtilsContext.width(element, true);
2406
2399
  recovery();
2407
2400
  return width;
2408
2401
  }
2409
2402
  }
2410
2403
  height(element, isShow = false) {
2411
- let DOMUtilsContext = this;
2404
+ const DOMUtilsContext = this;
2412
2405
  if (DOMUtilsCommonUtils.isWin(element)) {
2413
2406
  return DOMUtilsContext.windowApi.window.document.documentElement.clientHeight;
2414
2407
  }
2415
2408
  if (typeof element === "string") {
2416
2409
  element = DOMUtilsContext.selector(element);
2417
2410
  }
2418
- if (element == null) {
2419
- // @ts-ignore
2420
- return;
2421
- }
2422
2411
  if (element.nodeType === 9) {
2423
2412
  element = element;
2424
2413
  /* Document文档节点 */
@@ -2434,11 +2423,11 @@ var DOMUtils = (function () {
2434
2423
  }
2435
2424
  /* 如果从css里获取到的值不是大于0 可能是auto 则通过offsetHeight来进行计算 */
2436
2425
  if (element.offsetHeight > 0) {
2437
- let borderTopWidth = DOMUtilsCommonUtils.getStyleValue(element, "borderTopWidth");
2438
- let borderBottomWidth = DOMUtilsCommonUtils.getStyleValue(element, "borderBottomWidth");
2439
- let paddingTop = DOMUtilsCommonUtils.getStyleValue(element, "paddingTop");
2440
- let paddingBottom = DOMUtilsCommonUtils.getStyleValue(element, "paddingBottom");
2441
- let backHeight = parseFloat(element.offsetHeight.toString()) -
2426
+ const borderTopWidth = DOMUtilsCommonUtils.getStyleValue(element, "borderTopWidth");
2427
+ const borderBottomWidth = DOMUtilsCommonUtils.getStyleValue(element, "borderBottomWidth");
2428
+ const paddingTop = DOMUtilsCommonUtils.getStyleValue(element, "paddingTop");
2429
+ const paddingBottom = DOMUtilsCommonUtils.getStyleValue(element, "paddingBottom");
2430
+ const backHeight = parseFloat(element.offsetHeight.toString()) -
2442
2431
  parseFloat(borderTopWidth.toString()) -
2443
2432
  parseFloat(borderBottomWidth.toString()) -
2444
2433
  parseFloat(paddingTop.toString()) -
@@ -2450,60 +2439,52 @@ var DOMUtils = (function () {
2450
2439
  else {
2451
2440
  /* 未显示 */
2452
2441
  element = element;
2453
- let { recovery } = DOMUtilsCommonUtils.showElement(element);
2454
- let height = DOMUtilsContext.height(element, true);
2442
+ const { recovery } = DOMUtilsCommonUtils.showElement(element);
2443
+ const height = DOMUtilsContext.height(element, true);
2455
2444
  recovery();
2456
2445
  return height;
2457
2446
  }
2458
2447
  }
2459
2448
  outerWidth(element, isShow = false) {
2460
- let DOMUtilsContext = this;
2449
+ const DOMUtilsContext = this;
2461
2450
  if (DOMUtilsCommonUtils.isWin(element)) {
2462
2451
  return DOMUtilsContext.windowApi.window.innerWidth;
2463
2452
  }
2464
2453
  if (typeof element === "string") {
2465
2454
  element = DOMUtilsContext.selector(element);
2466
2455
  }
2467
- if (element == null) {
2468
- // @ts-ignore
2469
- return;
2470
- }
2471
2456
  element = element;
2472
2457
  if (isShow || (!isShow && DOMUtilsCommonUtils.isShow(element))) {
2473
- let style = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element, null);
2474
- let marginLeft = DOMUtilsCommonUtils.getStyleValue(style, "marginLeft");
2475
- let marginRight = DOMUtilsCommonUtils.getStyleValue(style, "marginRight");
2458
+ const style = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element, null);
2459
+ const marginLeft = DOMUtilsCommonUtils.getStyleValue(style, "marginLeft");
2460
+ const marginRight = DOMUtilsCommonUtils.getStyleValue(style, "marginRight");
2476
2461
  return element.offsetWidth + marginLeft + marginRight;
2477
2462
  }
2478
2463
  else {
2479
- let { recovery } = DOMUtilsCommonUtils.showElement(element);
2480
- let outerWidth = DOMUtilsContext.outerWidth(element, true);
2464
+ const { recovery } = DOMUtilsCommonUtils.showElement(element);
2465
+ const outerWidth = DOMUtilsContext.outerWidth(element, true);
2481
2466
  recovery();
2482
2467
  return outerWidth;
2483
2468
  }
2484
2469
  }
2485
2470
  outerHeight(element, isShow = false) {
2486
- let DOMUtilsContext = this;
2471
+ const DOMUtilsContext = this;
2487
2472
  if (DOMUtilsCommonUtils.isWin(element)) {
2488
2473
  return DOMUtilsContext.windowApi.window.innerHeight;
2489
2474
  }
2490
2475
  if (typeof element === "string") {
2491
2476
  element = DOMUtilsContext.selector(element);
2492
2477
  }
2493
- if (element == null) {
2494
- // @ts-ignore
2495
- return;
2496
- }
2497
2478
  element = element;
2498
2479
  if (isShow || (!isShow && DOMUtilsCommonUtils.isShow(element))) {
2499
- let style = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element, null);
2500
- let marginTop = DOMUtilsCommonUtils.getStyleValue(style, "marginTop");
2501
- let marginBottom = DOMUtilsCommonUtils.getStyleValue(style, "marginBottom");
2480
+ const style = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element, null);
2481
+ const marginTop = DOMUtilsCommonUtils.getStyleValue(style, "marginTop");
2482
+ const marginBottom = DOMUtilsCommonUtils.getStyleValue(style, "marginBottom");
2502
2483
  return element.offsetHeight + marginTop + marginBottom;
2503
2484
  }
2504
2485
  else {
2505
- let { recovery } = DOMUtilsCommonUtils.showElement(element);
2506
- let outerHeight = DOMUtilsContext.outerHeight(element, true);
2486
+ const { recovery } = DOMUtilsCommonUtils.showElement(element);
2487
+ const outerHeight = DOMUtilsContext.outerHeight(element, true);
2507
2488
  recovery();
2508
2489
  return outerHeight;
2509
2490
  }
@@ -2521,7 +2502,7 @@ var DOMUtils = (function () {
2521
2502
  * })
2522
2503
  */
2523
2504
  animate(element, styles, duration = 1000, callback = null) {
2524
- let DOMUtilsContext = this;
2505
+ const DOMUtilsContext = this;
2525
2506
  if (typeof element === "string") {
2526
2507
  element = DOMUtilsContext.selectorAll(element);
2527
2508
  }
@@ -2547,21 +2528,20 @@ var DOMUtils = (function () {
2547
2528
  if (Object.keys(styles).length === 0) {
2548
2529
  throw new Error("styles must contain at least one property");
2549
2530
  }
2550
- let start = performance.now();
2551
- let from = {};
2552
- let to = {};
2553
- for (let prop in styles) {
2554
- from[prop] =
2555
- element.style[prop] || DOMUtilsContext.windowApi.globalThis.getComputedStyle(element)[prop];
2531
+ const start = performance.now();
2532
+ const from = {};
2533
+ const to = {};
2534
+ for (const prop in styles) {
2535
+ from[prop] = element.style[prop] || DOMUtilsContext.windowApi.globalThis.getComputedStyle(element)[prop];
2556
2536
  to[prop] = styles[prop];
2557
2537
  }
2558
- let timer = DOMUtilsCommonUtils.setInterval(function () {
2559
- let timePassed = performance.now() - start;
2538
+ const timer = DOMUtilsCommonUtils.setInterval(function () {
2539
+ const timePassed = performance.now() - start;
2560
2540
  let progress = timePassed / duration;
2561
2541
  if (progress > 1) {
2562
2542
  progress = 1;
2563
2543
  }
2564
- for (let prop in styles) {
2544
+ for (const prop in styles) {
2565
2545
  element.style[prop] = from[prop] + (to[prop] - from[prop]) * progress + "px";
2566
2546
  }
2567
2547
  if (progress === 1) {
@@ -2581,7 +2561,7 @@ var DOMUtils = (function () {
2581
2561
  * DOMUtils.wrap(document.querySelector("a.xx"),"<div></div>")
2582
2562
  */
2583
2563
  wrap(element, wrapperHTML) {
2584
- let DOMUtilsContext = this;
2564
+ const DOMUtilsContext = this;
2585
2565
  if (typeof element === "string") {
2586
2566
  element = DOMUtilsContext.selectorAll(element);
2587
2567
  }
@@ -2597,17 +2577,17 @@ var DOMUtils = (function () {
2597
2577
  }
2598
2578
  element = element;
2599
2579
  // 创建一个新的div元素,并将wrapperHTML作为其innerHTML
2600
- let wrapper = DOMUtilsContext.windowApi.document.createElement("div");
2580
+ const wrapper = DOMUtilsContext.windowApi.document.createElement("div");
2601
2581
  DOMUtilsContext.html(wrapper, wrapperHTML);
2602
- let wrapperFirstChild = wrapper.firstChild;
2582
+ const wrapperFirstChild = wrapper.firstChild;
2603
2583
  // 将要包裹的元素插入目标元素前面
2604
- let parentElement = element.parentElement;
2584
+ const parentElement = element.parentElement;
2605
2585
  parentElement.insertBefore(wrapperFirstChild, element);
2606
2586
  // 将要包裹的元素移动到wrapper中
2607
2587
  wrapperFirstChild.appendChild(element);
2608
2588
  }
2609
2589
  prev(element) {
2610
- let DOMUtilsContext = this;
2590
+ const DOMUtilsContext = this;
2611
2591
  if (typeof element === "string") {
2612
2592
  element = DOMUtilsContext.selector(element);
2613
2593
  }
@@ -2617,7 +2597,7 @@ var DOMUtils = (function () {
2617
2597
  return element.previousElementSibling;
2618
2598
  }
2619
2599
  next(element) {
2620
- let DOMUtilsContext = this;
2600
+ const DOMUtilsContext = this;
2621
2601
  if (typeof element === "string") {
2622
2602
  element = DOMUtilsContext.selector(element);
2623
2603
  }
@@ -2632,7 +2612,7 @@ var DOMUtils = (function () {
2632
2612
  * let DOMUtils = window.DOMUtils.noConflict()
2633
2613
  */
2634
2614
  noConflict() {
2635
- let DOMUtilsContext = this;
2615
+ const DOMUtilsContext = this;
2636
2616
  if (DOMUtilsContext.windowApi.window.DOMUtils) {
2637
2617
  DOMUtilsCommonUtils.delete(window, "DOMUtils");
2638
2618
  }
@@ -2640,7 +2620,7 @@ var DOMUtils = (function () {
2640
2620
  return this;
2641
2621
  }
2642
2622
  siblings(element) {
2643
- let DOMUtilsContext = this;
2623
+ const DOMUtilsContext = this;
2644
2624
  if (typeof element === "string") {
2645
2625
  element = DOMUtilsContext.selector(element);
2646
2626
  }
@@ -2660,7 +2640,7 @@ var DOMUtils = (function () {
2660
2640
  * > <div ...>....</div>
2661
2641
  */
2662
2642
  parent(element) {
2663
- let DOMUtilsContext = this;
2643
+ const DOMUtilsContext = this;
2664
2644
  if (typeof element === "string") {
2665
2645
  element = DOMUtilsContext.selector(element);
2666
2646
  }
@@ -2668,7 +2648,7 @@ var DOMUtils = (function () {
2668
2648
  return;
2669
2649
  }
2670
2650
  if (DOMUtilsCommonUtils.isNodeList(element)) {
2671
- let resultArray = [];
2651
+ const resultArray = [];
2672
2652
  element.forEach(($ele) => {
2673
2653
  resultArray.push(DOMUtilsContext.parent($ele));
2674
2654
  });
@@ -2679,11 +2659,11 @@ var DOMUtils = (function () {
2679
2659
  }
2680
2660
  }
2681
2661
  parseHTML(html, useParser = false, isComplete = false) {
2682
- let DOMUtilsContext = this;
2662
+ const DOMUtilsContext = this;
2683
2663
  // 去除html前后的空格
2684
2664
  html = html.trim();
2685
2665
  function parseHTMLByDOMParser() {
2686
- let parser = new DOMParser();
2666
+ const parser = new DOMParser();
2687
2667
  if (isComplete) {
2688
2668
  return parser.parseFromString(html, "text/html");
2689
2669
  }
@@ -2692,7 +2672,7 @@ var DOMUtils = (function () {
2692
2672
  }
2693
2673
  }
2694
2674
  function parseHTMLByCreateDom() {
2695
- let tempDIV = DOMUtilsContext.windowApi.document.createElement("div");
2675
+ const tempDIV = DOMUtilsContext.windowApi.document.createElement("div");
2696
2676
  DOMUtilsContext.html(tempDIV, html);
2697
2677
  if (isComplete) {
2698
2678
  return tempDIV;
@@ -2717,7 +2697,7 @@ var DOMUtils = (function () {
2717
2697
  */
2718
2698
  serialize($form) {
2719
2699
  const elements = $form.elements;
2720
- let serializedArray = [];
2700
+ const serializedArray = [];
2721
2701
  for (let i = 0; i < elements.length; i++) {
2722
2702
  const element = elements[i];
2723
2703
  if (element.name &&
@@ -2756,7 +2736,7 @@ var DOMUtils = (function () {
2756
2736
  * DOMUtils.show("a.xx")
2757
2737
  */
2758
2738
  show(target, checkVisiblie = true) {
2759
- let DOMUtilsContext = this;
2739
+ const DOMUtilsContext = this;
2760
2740
  if (target == null) {
2761
2741
  return;
2762
2742
  }
@@ -2793,7 +2773,7 @@ var DOMUtils = (function () {
2793
2773
  * DOMUtils.hide("a.xx")
2794
2774
  */
2795
2775
  hide(target, checkVisiblie = true) {
2796
- let DOMUtilsContext = this;
2776
+ const DOMUtilsContext = this;
2797
2777
  if (target == null) {
2798
2778
  return;
2799
2779
  }
@@ -2835,7 +2815,7 @@ var DOMUtils = (function () {
2835
2815
  if (element == null) {
2836
2816
  return;
2837
2817
  }
2838
- let DOMUtilsContext = this;
2818
+ const DOMUtilsContext = this;
2839
2819
  if (typeof element === "string") {
2840
2820
  element = DOMUtilsContext.selectorAll(element);
2841
2821
  }
@@ -2853,7 +2833,7 @@ var DOMUtils = (function () {
2853
2833
  function step(timestamp) {
2854
2834
  if (!start)
2855
2835
  start = timestamp;
2856
- let progress = timestamp - start;
2836
+ const progress = timestamp - start;
2857
2837
  element = element;
2858
2838
  element.style.opacity = Math.min(progress / duration, 1).toString();
2859
2839
  if (progress < duration) {
@@ -2883,7 +2863,7 @@ var DOMUtils = (function () {
2883
2863
  * })
2884
2864
  */
2885
2865
  fadeOut(element, duration = 400, callback) {
2886
- let DOMUtilsContext = this;
2866
+ const DOMUtilsContext = this;
2887
2867
  if (element == null) {
2888
2868
  return;
2889
2869
  }
@@ -2903,7 +2883,7 @@ var DOMUtils = (function () {
2903
2883
  function step(timestamp) {
2904
2884
  if (!start)
2905
2885
  start = timestamp;
2906
- let progress = timestamp - start;
2886
+ const progress = timestamp - start;
2907
2887
  element = element;
2908
2888
  element.style.opacity = Math.max(1 - progress / duration, 0).toString();
2909
2889
  if (progress < duration) {
@@ -2929,7 +2909,7 @@ var DOMUtils = (function () {
2929
2909
  * DOMUtils.toggle("a.xx")
2930
2910
  */
2931
2911
  toggle(element, checkVisiblie) {
2932
- let DOMUtilsContext = this;
2912
+ const DOMUtilsContext = this;
2933
2913
  if (typeof element === "string") {
2934
2914
  element = DOMUtilsContext.selectorAll(element);
2935
2915
  }
@@ -2967,7 +2947,7 @@ var DOMUtils = (function () {
2967
2947
  * DOMUtils.getTextBoundingRect(document.querySelector("input"));
2968
2948
  */
2969
2949
  getTextBoundingRect($input, selectionStart, selectionEnd) {
2970
- let DOMUtilsContext = this;
2950
+ const DOMUtilsContext = this;
2971
2951
  // Basic parameter validation
2972
2952
  if (!$input || !("value" in $input))
2973
2953
  return $input;
@@ -2996,18 +2976,20 @@ var DOMUtils = (function () {
2996
2976
  else
2997
2977
  selectionEnd = Math.min($input.value.length, selectionEnd);
2998
2978
  // If available (thus IE), use the createTextRange method
2999
- // @ts-ignore
3000
2979
  if (typeof $input.createTextRange == "function") {
3001
- let range = $input.createTextRange();
2980
+ const range = $input.createTextRange();
3002
2981
  range.collapse(true);
3003
2982
  range.moveStart("character", selectionStart);
3004
2983
  range.moveEnd("character", selectionEnd - selectionStart);
3005
2984
  return range.getBoundingClientRect();
3006
2985
  }
3007
2986
  // createTextRange is not supported, create a fake text range
3008
- let offset = getInputOffset(), topPos = offset.top, leftPos = offset.left, width = getInputCSS("width", true), height = getInputCSS("height", true);
2987
+ const offset = getInputOffset(), width = getInputCSS("width", true), height = getInputCSS("height", true);
2988
+ let topPos = offset.top;
2989
+ let leftPos = offset.left;
3009
2990
  // Styles to simulate a node in an input field
3010
- let cssDefaultStyles = "white-space:pre;padding:0;margin:0;", listOfModifiers = [
2991
+ let cssDefaultStyles = "white-space:pre;padding:0;margin:0;";
2992
+ const listOfModifiers = [
3011
2993
  "direction",
3012
2994
  "font-family",
3013
2995
  "font-size",
@@ -3029,16 +3011,15 @@ var DOMUtils = (function () {
3029
3011
  leftPos += getInputCSS("border-left-width", true);
3030
3012
  leftPos += 1; //Seems to be necessary
3031
3013
  for (let index = 0; index < listOfModifiers.length; index++) {
3032
- let property = listOfModifiers[index];
3033
- // @ts-ignore
3034
- cssDefaultStyles += property + ":" + getInputCSS(property) + ";";
3014
+ const property = listOfModifiers[index];
3015
+ cssDefaultStyles += property + ":" + getInputCSS(property, false) + ";";
3035
3016
  }
3036
3017
  // End of CSS variable checks
3037
3018
  // 不能为空,不然获取不到高度
3038
- let text = $input.value || "G", textLen = text.length, fakeClone = DOMUtilsContext.windowApi.document.createElement("div");
3019
+ const text = $input.value || "G", textLen = text.length, fakeClone = DOMUtilsContext.windowApi.document.createElement("div");
3039
3020
  if (selectionStart > 0)
3040
3021
  appendPart(0, selectionStart);
3041
- var fakeRange = appendPart(selectionStart, selectionEnd);
3022
+ const fakeRange = appendPart(selectionStart, selectionEnd);
3042
3023
  if (textLen > selectionEnd)
3043
3024
  appendPart(selectionEnd, textLen);
3044
3025
  // Styles to inherit the font styles of the element
@@ -3050,7 +3031,7 @@ var DOMUtils = (function () {
3050
3031
  fakeClone.style.width = width + "px";
3051
3032
  fakeClone.style.height = height + "px";
3052
3033
  DOMUtilsContext.windowApi.document.body.appendChild(fakeClone);
3053
- var returnValue = fakeRange.getBoundingClientRect(); //Get rect
3034
+ const returnValue = fakeRange.getBoundingClientRect(); //Get rect
3054
3035
  fakeClone?.parentNode?.removeChild(fakeClone); //Remove temp
3055
3036
  return returnValue;
3056
3037
  // Local functions for readability of the previous code
@@ -3061,7 +3042,7 @@ var DOMUtils = (function () {
3061
3042
  * @returns
3062
3043
  */
3063
3044
  function appendPart(start, end) {
3064
- var span = DOMUtilsContext.windowApi.document.createElement("span");
3045
+ const span = DOMUtilsContext.windowApi.document.createElement("span");
3065
3046
  span.style.cssText = cssDefaultStyles; //Force styles to prevent unexpected results
3066
3047
  span.textContent = text.substring(start, end);
3067
3048
  fakeClone.appendChild(span);
@@ -3069,13 +3050,13 @@ var DOMUtils = (function () {
3069
3050
  }
3070
3051
  // Computing offset position
3071
3052
  function getInputOffset() {
3072
- let body = DOMUtilsContext.windowApi.document.body, win = DOMUtilsContext.windowApi.document.defaultView, docElem = DOMUtilsContext.windowApi.document.documentElement, $box = DOMUtilsContext.windowApi.document.createElement("div");
3053
+ const body = DOMUtilsContext.windowApi.document.body, win = DOMUtilsContext.windowApi.document.defaultView, docElem = DOMUtilsContext.windowApi.document.documentElement, $box = DOMUtilsContext.windowApi.document.createElement("div");
3073
3054
  $box.style.paddingLeft = $box.style.width = "1px";
3074
3055
  body.appendChild($box);
3075
- var isBoxModel = $box.offsetWidth == 2;
3056
+ const isBoxModel = $box.offsetWidth == 2;
3076
3057
  body.removeChild($box);
3077
- let $boxRect = $input.getBoundingClientRect();
3078
- var clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, scrollTop = win.pageYOffset || (isBoxModel && docElem.scrollTop) || body.scrollTop, scrollLeft = win.pageXOffset || (isBoxModel && docElem.scrollLeft) || body.scrollLeft;
3058
+ const $boxRect = $input.getBoundingClientRect();
3059
+ const clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, scrollTop = win.pageYOffset || (isBoxModel && docElem.scrollTop) || body.scrollTop, scrollLeft = win.pageXOffset || (isBoxModel && docElem.scrollLeft) || body.scrollLeft;
3079
3060
  return {
3080
3061
  top: $boxRect.top + scrollTop - clientTop,
3081
3062
  left: $boxRect.left + scrollLeft - clientLeft,
@@ -3088,10 +3069,13 @@ var DOMUtils = (function () {
3088
3069
  * @returns
3089
3070
  */
3090
3071
  function getInputCSS(prop, isNumber) {
3091
- var val = DOMUtilsContext.windowApi.document
3092
- .defaultView.getComputedStyle($input, null)
3093
- .getPropertyValue(prop);
3094
- return isNumber ? parseFloat(val) : val;
3072
+ const val = DOMUtilsContext.windowApi.document.defaultView.getComputedStyle($input, null).getPropertyValue(prop);
3073
+ if (isNumber) {
3074
+ return parseFloat(val);
3075
+ }
3076
+ else {
3077
+ return val;
3078
+ }
3095
3079
  }
3096
3080
  }
3097
3081
  /** 获取 animationend 在各个浏览器的兼容名 */
@@ -3103,7 +3087,7 @@ var DOMUtils = (function () {
3103
3087
  return DOMUtilsCommonUtils.getTransitionEndNameList();
3104
3088
  }
3105
3089
  }
3106
- let domUtils = new DOMUtils();
3090
+ const domUtils = new DOMUtils();
3107
3091
 
3108
3092
  return domUtils;
3109
3093