@whitesev/domutils 1.6.6 → 1.6.8

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
@@ -323,10 +323,8 @@ const DOMUtilsCommonUtils = {
323
323
  * 获取安全的html
324
324
  */
325
325
  getSafeHTML(text) {
326
- // @ts-ignore
327
- if (globalThis.trustedTypes) {
328
- // @ts-ignore
329
- const policy = globalThis.trustedTypes.createPolicy("safe-innerHTML", {
326
+ if (window.trustedTypes) {
327
+ const policy = window.trustedTypes.createPolicy("safe-innerHTML", {
330
328
  createHTML: (html) => html,
331
329
  });
332
330
  return policy.createHTML(text);
@@ -349,7 +347,7 @@ const DOMUtilsCommonUtils = {
349
347
  * @param element
350
348
  */
351
349
  showElement(element) {
352
- let dupNode = element.cloneNode(true);
350
+ const dupNode = element.cloneNode(true);
353
351
  dupNode.setAttribute("style", "visibility: hidden !important;display:block !important;");
354
352
  this.windowApi.document.documentElement.appendChild(dupNode);
355
353
  return {
@@ -380,7 +378,7 @@ const DOMUtilsCommonUtils = {
380
378
  }
381
379
  styles = view.getComputedStyle(element);
382
380
  }
383
- let value = parseFloat(styles[styleName]);
381
+ const value = parseFloat(styles[styleName]);
384
382
  if (isNaN(value)) {
385
383
  return 0;
386
384
  }
@@ -431,8 +429,8 @@ const DOMUtilsCommonUtils = {
431
429
  * @param propName
432
430
  */
433
431
  delete(target, propName) {
434
- if (typeof Reflect === "object" && Reflect.deleteProperty) {
435
- Reflect.deleteProperty(target, propName);
432
+ if (typeof Reflect === "object" && Reflect != null && Reflect.deleteProperty) {
433
+ return Reflect.deleteProperty(target, propName);
436
434
  }
437
435
  else {
438
436
  delete target[propName];
@@ -445,7 +443,7 @@ const DOMUtilsCommonUtils = {
445
443
  try {
446
444
  return setTimeout$1(callback, timeout);
447
445
  }
448
- catch (error) {
446
+ catch {
449
447
  return this.windowApi.setTimeout(callback, timeout);
450
448
  }
451
449
  },
@@ -458,7 +456,8 @@ const DOMUtilsCommonUtils = {
458
456
  clearTimeout$1(timeId);
459
457
  }
460
458
  }
461
- catch (error) {
459
+ catch {
460
+ // TODO
462
461
  }
463
462
  finally {
464
463
  this.windowApi.clearTimeout(timeId);
@@ -471,7 +470,7 @@ const DOMUtilsCommonUtils = {
471
470
  try {
472
471
  return setInterval$1(callback, timeout);
473
472
  }
474
- catch (error) {
473
+ catch {
475
474
  return this.windowApi.setInterval(callback, timeout);
476
475
  }
477
476
  },
@@ -484,7 +483,8 @@ const DOMUtilsCommonUtils = {
484
483
  clearInterval$1(timeId);
485
484
  }
486
485
  }
487
- catch (error) {
486
+ catch {
487
+ // TODO
488
488
  }
489
489
  finally {
490
490
  this.windowApi.clearInterval(timeId);
@@ -532,7 +532,7 @@ class DOMUtilsEvent {
532
532
  * @param option
533
533
  */
534
534
  function getOption(args, startIndex, option) {
535
- let currentParam = args[startIndex];
535
+ const currentParam = args[startIndex];
536
536
  if (typeof currentParam === "boolean") {
537
537
  option.capture = currentParam;
538
538
  if (typeof args[startIndex + 1] === "boolean") {
@@ -554,8 +554,9 @@ class DOMUtilsEvent {
554
554
  }
555
555
  return option;
556
556
  }
557
- let DOMUtilsContext = this;
558
- let args = arguments;
557
+ const DOMUtilsContext = this;
558
+ // eslint-disable-next-line prefer-rest-params
559
+ const args = arguments;
559
560
  if (typeof element === "string") {
560
561
  element = DOMUtilsContext.selectorAll(element);
561
562
  }
@@ -631,14 +632,14 @@ class DOMUtilsEvent {
631
632
  totalParent = DOMUtilsContext.windowApi.document.documentElement;
632
633
  }
633
634
  }
634
- let findValue = selectorList.find((selectorItem) => {
635
+ const findValue = selectorList.find((selectorItem) => {
635
636
  // 判断目标元素是否匹配选择器
636
637
  if (DOMUtilsContext.matches(eventTarget, selectorItem)) {
637
638
  /* 当前目标可以被selector所匹配到 */
638
639
  return true;
639
640
  }
640
641
  /* 在上层与主元素之间寻找可以被selector所匹配到的 */
641
- let $closestMatches = DOMUtilsContext.closest(eventTarget, selectorItem);
642
+ const $closestMatches = DOMUtilsContext.closest(eventTarget, selectorItem);
642
643
  if ($closestMatches && totalParent?.contains($closestMatches)) {
643
644
  eventTarget = $closestMatches;
644
645
  return true;
@@ -654,7 +655,9 @@ class DOMUtilsEvent {
654
655
  },
655
656
  });
656
657
  }
657
- catch (error) { }
658
+ catch {
659
+ // TODO
660
+ }
658
661
  listenerCallBack.call(eventTarget, event, eventTarget);
659
662
  checkOptionOnceToRemoveEventListener();
660
663
  }
@@ -669,7 +672,7 @@ class DOMUtilsEvent {
669
672
  eventTypeList.forEach((eventName) => {
670
673
  elementItem.addEventListener(eventName, domUtilsEventCallBack, listenerOption);
671
674
  /* 获取对象上的事件 */
672
- let elementEvents = Reflect.get(elementItem, DOMUtilsData.SymbolEvents) || {};
675
+ const elementEvents = Reflect.get(elementItem, DOMUtilsData.SymbolEvents) || {};
673
676
  /* 初始化对象上的xx事件 */
674
677
  elementEvents[eventName] = elementEvents[eventName] || [];
675
678
  elementEvents[eventName].push({
@@ -691,17 +694,18 @@ class DOMUtilsEvent {
691
694
  * @param option
692
695
  */
693
696
  function getOption(args1, startIndex, option) {
694
- let currentParam = args1[startIndex];
697
+ const currentParam = args1[startIndex];
695
698
  if (typeof currentParam === "boolean") {
696
699
  option.capture = currentParam;
697
700
  }
698
- else if (typeof currentParam === "object" && "capture" in currentParam) {
701
+ else if (typeof currentParam === "object" && currentParam != null && "capture" in currentParam) {
699
702
  option.capture = currentParam.capture;
700
703
  }
701
704
  return option;
702
705
  }
703
- let DOMUtilsContext = this;
704
- let args = arguments;
706
+ const DOMUtilsContext = this;
707
+ // eslint-disable-next-line prefer-rest-params
708
+ const args = arguments;
705
709
  if (typeof element === "string") {
706
710
  element = DOMUtilsContext.selectorAll(element);
707
711
  }
@@ -761,16 +765,18 @@ class DOMUtilsEvent {
761
765
  // 目标函数、事件名、子元素选择器
762
766
  isRemoveAll = true;
763
767
  }
768
+ if (args.length === 5 && typeof args[4] === "function" && typeof filter !== "function") {
769
+ // 目标函数、事件名、回调函数、事件配置、过滤函数
770
+ filter = option;
771
+ }
764
772
  elementList.forEach((elementItem) => {
765
773
  /* 获取对象上的事件 */
766
- let elementEvents = Reflect.get(elementItem, DOMUtilsData.SymbolEvents) || {};
774
+ const elementEvents = Reflect.get(elementItem, DOMUtilsData.SymbolEvents) || {};
767
775
  eventTypeList.forEach((eventName) => {
768
- let handlers = elementEvents[eventName] || [];
769
- if (typeof filter === "function") {
770
- handlers = handlers.filter(filter);
771
- }
772
- for (let index = 0; index < handlers.length; index++) {
773
- let handler = handlers[index];
776
+ const handlers = elementEvents[eventName] || [];
777
+ const filterHandler = typeof filter === "function" ? handlers.filter(filter) : handlers;
778
+ for (let index = 0; index < filterHandler.length; index++) {
779
+ const handler = filterHandler[index];
774
780
  let flag = true;
775
781
  if (flag && listenerCallBack && handler.originCallBack !== listenerCallBack) {
776
782
  // callback不同
@@ -782,13 +788,18 @@ class DOMUtilsEvent {
782
788
  flag = false;
783
789
  }
784
790
  }
785
- if (flag && listenerOption.capture !== handler.option.capture) {
791
+ if (flag &&
792
+ typeof handler.option.capture === "boolean" &&
793
+ listenerOption.capture !== handler.option.capture) {
786
794
  // 事件的配置项不同
787
795
  flag = false;
788
796
  }
789
797
  if (flag || isRemoveAll) {
790
798
  elementItem.removeEventListener(eventName, handler.callback, handler.option);
791
- handlers.splice(index--, 1);
799
+ const findIndex = handlers.findIndex((item) => item === handler);
800
+ if (findIndex !== -1) {
801
+ handlers.splice(findIndex, 1);
802
+ }
792
803
  }
793
804
  }
794
805
  if (handlers.length === 0) {
@@ -805,7 +816,7 @@ class DOMUtilsEvent {
805
816
  * @param eventType (可选)需要取消监听的事件
806
817
  */
807
818
  offAll(element, eventType) {
808
- let DOMUtilsContext = this;
819
+ const DOMUtilsContext = this;
809
820
  if (typeof element === "string") {
810
821
  element = DOMUtilsContext.selectorAll(element);
811
822
  }
@@ -831,10 +842,10 @@ class DOMUtilsEvent {
831
842
  if (!symbolEvents.toString().startsWith("Symbol(events_")) {
832
843
  return;
833
844
  }
834
- let elementEvents = elementItem[symbolEvents] || {};
835
- let iterEventNameList = eventTypeList.length ? eventTypeList : Object.keys(elementEvents);
845
+ const elementEvents = elementItem[symbolEvents] || {};
846
+ const iterEventNameList = eventTypeList.length ? eventTypeList : Object.keys(elementEvents);
836
847
  iterEventNameList.forEach((eventName) => {
837
- let handlers = elementEvents[eventName];
848
+ const handlers = elementEvents[eventName];
838
849
  if (!handlers) {
839
850
  return;
840
851
  }
@@ -843,7 +854,7 @@ class DOMUtilsEvent {
843
854
  capture: handler["option"]["capture"],
844
855
  });
845
856
  }
846
- let events = Reflect.get(elementItem, symbolEvents);
857
+ const events = Reflect.get(elementItem, symbolEvents);
847
858
  DOMUtilsCommonUtils.delete(events, eventName);
848
859
  });
849
860
  });
@@ -861,7 +872,7 @@ class DOMUtilsEvent {
861
872
  if (typeof callback !== "function") {
862
873
  return;
863
874
  }
864
- let DOMUtilsContext = this;
875
+ const DOMUtilsContext = this;
865
876
  /**
866
877
  * 检测文档是否加载完毕
867
878
  */
@@ -876,7 +887,7 @@ class DOMUtilsEvent {
876
887
  return false;
877
888
  }
878
889
  }
879
- catch (error) {
890
+ catch {
880
891
  return false;
881
892
  }
882
893
  }
@@ -887,7 +898,7 @@ class DOMUtilsEvent {
887
898
  removeDomReadyListener();
888
899
  callback();
889
900
  }
890
- let targetList = [
901
+ const targetList = [
891
902
  {
892
903
  target: DOMUtilsContext.windowApi.document,
893
904
  eventType: "DOMContentLoaded",
@@ -904,7 +915,7 @@ class DOMUtilsEvent {
904
915
  */
905
916
  function addDomReadyListener() {
906
917
  for (let index = 0; index < targetList.length; index++) {
907
- let item = targetList[index];
918
+ const item = targetList[index];
908
919
  item.target.addEventListener(item.eventType, item.callback);
909
920
  }
910
921
  }
@@ -913,7 +924,7 @@ class DOMUtilsEvent {
913
924
  */
914
925
  function removeDomReadyListener() {
915
926
  for (let index = 0; index < targetList.length; index++) {
916
- let item = targetList[index];
927
+ const item = targetList[index];
917
928
  item.target.removeEventListener(item.eventType, item.callback);
918
929
  }
919
930
  }
@@ -941,7 +952,7 @@ class DOMUtilsEvent {
941
952
  * DOMUtils.trigger("a.xx",["click","tap","hover"])
942
953
  */
943
954
  trigger(element, eventType, details, useDispatchToTriggerEvent = true) {
944
- let DOMUtilsContext = this;
955
+ const DOMUtilsContext = this;
945
956
  if (typeof element === "string") {
946
957
  element = DOMUtilsContext.selectorAll(element);
947
958
  }
@@ -965,7 +976,7 @@ class DOMUtilsEvent {
965
976
  }
966
977
  elementList.forEach((elementItem) => {
967
978
  /* 获取对象上的事件 */
968
- let events = elementItem[DOMUtilsData.SymbolEvents] || {};
979
+ const events = elementItem[DOMUtilsData.SymbolEvents] || {};
969
980
  eventTypeList.forEach((_eventType_) => {
970
981
  let event = null;
971
982
  if (details && details instanceof Event) {
@@ -1005,7 +1016,7 @@ class DOMUtilsEvent {
1005
1016
  * })
1006
1017
  * */
1007
1018
  click(element, handler, details, useDispatchToTriggerEvent) {
1008
- let DOMUtilsContext = this;
1019
+ const DOMUtilsContext = this;
1009
1020
  if (typeof element === "string") {
1010
1021
  element = DOMUtilsContext.selectorAll(element);
1011
1022
  }
@@ -1041,7 +1052,7 @@ class DOMUtilsEvent {
1041
1052
  * })
1042
1053
  * */
1043
1054
  blur(element, handler, details, useDispatchToTriggerEvent) {
1044
- let DOMUtilsContext = this;
1055
+ const DOMUtilsContext = this;
1045
1056
  if (typeof element === "string") {
1046
1057
  element = DOMUtilsContext.selectorAll(element);
1047
1058
  }
@@ -1077,7 +1088,7 @@ class DOMUtilsEvent {
1077
1088
  * })
1078
1089
  * */
1079
1090
  focus(element, handler, details, useDispatchToTriggerEvent) {
1080
- let DOMUtilsContext = this;
1091
+ const DOMUtilsContext = this;
1081
1092
  if (typeof element === "string") {
1082
1093
  element = DOMUtilsContext.selectorAll(element);
1083
1094
  }
@@ -1113,7 +1124,7 @@ class DOMUtilsEvent {
1113
1124
  * })
1114
1125
  */
1115
1126
  hover(element, handler, option) {
1116
- let DOMUtilsContext = this;
1127
+ const DOMUtilsContext = this;
1117
1128
  if (typeof element === "string") {
1118
1129
  element = DOMUtilsContext.selectorAll(element);
1119
1130
  }
@@ -1137,7 +1148,7 @@ class DOMUtilsEvent {
1137
1148
  * @param option 配置项,这里默认配置once为true
1138
1149
  */
1139
1150
  animationend(element, handler, option) {
1140
- let DOMUtilsContext = this;
1151
+ const DOMUtilsContext = this;
1141
1152
  if (typeof element === "string") {
1142
1153
  element = DOMUtilsContext.selector(element);
1143
1154
  }
@@ -1172,7 +1183,7 @@ class DOMUtilsEvent {
1172
1183
  * @param option 配置项,这里默认配置once为true
1173
1184
  */
1174
1185
  transitionend(element, handler, option) {
1175
- let DOMUtilsContext = this;
1186
+ const DOMUtilsContext = this;
1176
1187
  if (typeof element === "string") {
1177
1188
  element = DOMUtilsContext.selector(element);
1178
1189
  }
@@ -1216,7 +1227,7 @@ class DOMUtilsEvent {
1216
1227
  * })
1217
1228
  */
1218
1229
  keyup(element, handler, option) {
1219
- let DOMUtilsContext = this;
1230
+ const DOMUtilsContext = this;
1220
1231
  if (element == null) {
1221
1232
  return;
1222
1233
  }
@@ -1248,7 +1259,7 @@ class DOMUtilsEvent {
1248
1259
  * })
1249
1260
  */
1250
1261
  keydown(element, handler, option) {
1251
- let DOMUtilsContext = this;
1262
+ const DOMUtilsContext = this;
1252
1263
  if (element == null) {
1253
1264
  return;
1254
1265
  }
@@ -1280,7 +1291,7 @@ class DOMUtilsEvent {
1280
1291
  * })
1281
1292
  */
1282
1293
  keypress(element, handler, option) {
1283
- let DOMUtilsContext = this;
1294
+ const DOMUtilsContext = this;
1284
1295
  if (element == null) {
1285
1296
  return;
1286
1297
  }
@@ -1297,80 +1308,80 @@ class DOMUtilsEvent {
1297
1308
  DOMUtilsContext.on(element, "keypress", null, handler, option);
1298
1309
  }
1299
1310
  /**
1300
- * 监听某个元素键盘按键事件或window全局按键事件
1301
- * 按下有值的键时触发,按下Ctrl\Alt\Shift\Meta是无值键。按下先触发keydown事件,再触发keypress事件。
1302
- * @param element 需要监听的对象,可以是全局Window或者某个元素
1303
- * @param eventName 事件名,默认keypress
1304
- * @param callback 自己定义的回调事件,参数1为当前的key,参数2为组合按键,数组类型,包含ctrl、shift、alt和meta(win键或mac的cmd键)
1305
- * @param options 监听事件的配置
1306
- * @example
1307
- Utils.listenKeyboard(window,(keyName,keyValue,otherKey,event)=>{
1308
- if(keyName === "Enter"){
1309
- console.log("回车按键的值是:"+keyValue)
1310
- }
1311
- if(otherKey.indexOf("ctrl") && keyName === "Enter" ){
1312
- console.log("Ctrl和回车键");
1313
- }
1314
- })
1315
- * @example
1316
- 字母和数字键的键码值(keyCode)
1317
- 按键 键码 按键 键码 按键 键码 按键 键码
1318
- A 65 J 74 S 83 1 49
1319
- B 66 K 75 T 84 2 50
1320
- C 67 L 76 U 85 3 51
1321
- D 68 M 77 V 86 4 52
1322
- E 69 N 78 W 87 5 53
1323
- F 70 O 79 X 88 6 54
1324
- G 71 P 80 Y 89 7 55
1325
- H 72 Q 81 Z 90 8 56
1326
- I 73 R 82 0 48 9 57
1327
-
1328
- 数字键盘上的键的键码值(keyCode)
1329
- 功能键键码值(keyCode)
1330
- 按键 键码 按键 键码 按键 键码 按键 键码
1331
- 0 96 8 104 F1 112 F7 118
1332
- 1 97 9 105 F2 113 F8 119
1333
- 2 98 * 106 F3 114 F9 120
1334
- 3 99 + 107 F4 115 F10 121
1335
- 4 100 Enter 108 F5 116 F11 122
1336
- 5 101 - 109 F6 117 F12 123
1337
- 6 102 . 110
1338
- 7 103 / 111
1339
-
1340
- 控制键键码值(keyCode)
1341
- 按键 键码 按键 键码 按键 键码 按键 键码
1342
- BackSpace 8 Esc 27 → 39 -_ 189
1343
- Tab 9 Spacebar 32 ↓ 40 .> 190
1344
- Clear 12 Page Up 33 Insert 45 /? 191
1345
- Enter 13 Page Down 34 Delete 46 `~ 192
1346
- Shift 16 End 35 Num Lock 144 [{ 219
1347
- Control 17 Home 36 ;: 186 \| 220
1348
- Alt 18 ← 37 =+ 187 ]} 221
1349
- Cape Lock 20 ↑ 38 ,< 188 '" 222
1350
-
1351
- 多媒体键码值(keyCode)
1352
- 按键 键码
1353
- 音量加 175
1354
- 音量减 174
1355
- 停止 179
1356
- 静音 173
1357
- 浏览器 172
1358
- 邮件 180
1359
- 搜索 170
1360
- 收藏 171
1361
- **/
1311
+ * 监听某个元素键盘按键事件或window全局按键事件
1312
+ * 按下有值的键时触发,按下Ctrl\Alt\Shift\Meta是无值键。按下先触发keydown事件,再触发keypress事件。
1313
+ * @param element 需要监听的对象,可以是全局Window或者某个元素
1314
+ * @param eventName 事件名,默认keypress
1315
+ * @param callback 自己定义的回调事件,参数1为当前的key,参数2为组合按键,数组类型,包含ctrl、shift、alt和meta(win键或mac的cmd键)
1316
+ * @param options 监听事件的配置
1317
+ * @example
1318
+ Utils.listenKeyboard(window,(keyName,keyValue,otherKey,event)=>{
1319
+ if(keyName === "Enter"){
1320
+ console.log("回车按键的值是:"+keyValue)
1321
+ }
1322
+ if(otherKey.indexOf("ctrl") && keyName === "Enter" ){
1323
+ console.log("Ctrl和回车键");
1324
+ }
1325
+ })
1326
+ * @example
1327
+ 字母和数字键的键码值(keyCode)
1328
+ 按键 键码 按键 键码 按键 键码 按键 键码
1329
+ A 65 J 74 S 83 1 49
1330
+ B 66 K 75 T 84 2 50
1331
+ C 67 L 76 U 85 3 51
1332
+ D 68 M 77 V 86 4 52
1333
+ E 69 N 78 W 87 5 53
1334
+ F 70 O 79 X 88 6 54
1335
+ G 71 P 80 Y 89 7 55
1336
+ H 72 Q 81 Z 90 8 56
1337
+ I 73 R 82 0 48 9 57
1338
+
1339
+ 数字键盘上的键的键码值(keyCode)
1340
+ 功能键键码值(keyCode)
1341
+ 按键 键码 按键 键码 按键 键码 按键 键码
1342
+ 0 96 8 104 F1 112 F7 118
1343
+ 1 97 9 105 F2 113 F8 119
1344
+ 2 98 * 106 F3 114 F9 120
1345
+ 3 99 + 107 F4 115 F10 121
1346
+ 4 100 Enter 108 F5 116 F11 122
1347
+ 5 101 - 109 F6 117 F12 123
1348
+ 6 102 . 110
1349
+ 7 103 / 111
1350
+
1351
+ 控制键键码值(keyCode)
1352
+ 按键 键码 按键 键码 按键 键码 按键 键码
1353
+ BackSpace 8 Esc 27 → 39 -_ 189
1354
+ Tab 9 Spacebar 32 ↓ 40 .> 190
1355
+ Clear 12 Page Up 33 Insert 45 /? 191
1356
+ Enter 13 Page Down 34 Delete 46 `~ 192
1357
+ Shift 16 End 35 Num Lock 144 [{ 219
1358
+ Control 17 Home 36 ;: 186 \| 220
1359
+ Alt 18 ← 37 =+ 187 ]} 221
1360
+ Cape Lock 20 ↑ 38 ,< 188 '" 222
1361
+
1362
+ 多媒体键码值(keyCode)
1363
+ 按键 键码
1364
+ 音量加 175
1365
+ 音量减 174
1366
+ 停止 179
1367
+ 静音 173
1368
+ 浏览器 172
1369
+ 邮件 180
1370
+ 搜索 170
1371
+ 收藏 171
1372
+ **/
1362
1373
  listenKeyboard(element, eventName = "keypress", callback, options) {
1363
- let DOMUtilsContext = this;
1374
+ const DOMUtilsContext = this;
1364
1375
  if (typeof element === "string") {
1365
1376
  element = DOMUtilsContext.selectorAll(element);
1366
1377
  }
1367
- let keyboardEventCallBack = function (event) {
1378
+ const keyboardEventCallBack = function (event) {
1368
1379
  /** 键名 */
1369
- let keyName = event.key || event.code;
1380
+ const keyName = event.key || event.code;
1370
1381
  /** 键值 */
1371
- let keyValue = event.charCode || event.keyCode || event.which;
1382
+ const keyValue = event.charCode || event.keyCode || event.which;
1372
1383
  /** 组合键列表 */
1373
- let otherCodeList = [];
1384
+ const otherCodeList = [];
1374
1385
  if (event.ctrlKey) {
1375
1386
  otherCodeList.push("ctrl");
1376
1387
  }
@@ -1408,29 +1419,27 @@ class DOMUtilsEvent {
1408
1419
  return $ele?.innerHTML?.trim() === "";
1409
1420
  });
1410
1421
  }
1411
- else if (selector.match(/[^\s]{1}:contains\("(.*)"\)$/i) ||
1412
- selector.match(/[^\s]{1}:contains\('(.*)'\)$/i)) {
1422
+ else if (selector.match(/[^\s]{1}:contains\("(.*)"\)$/i) || selector.match(/[^\s]{1}:contains\('(.*)'\)$/i)) {
1413
1423
  // contains 语法
1414
- let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
1415
- let text = textMatch[2];
1424
+ const textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
1425
+ const text = textMatch[2];
1416
1426
  selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
1417
1427
  return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
1418
1428
  // @ts-ignore
1419
1429
  return ($ele?.textContent || $ele?.innerText)?.includes(text);
1420
1430
  });
1421
1431
  }
1422
- else if (selector.match(/[^\s]{1}:regexp\("(.*)"\)$/i) ||
1423
- selector.match(/[^\s]{1}:regexp\('(.*)'\)$/i)) {
1432
+ else if (selector.match(/[^\s]{1}:regexp\("(.*)"\)$/i) || selector.match(/[^\s]{1}:regexp\('(.*)'\)$/i)) {
1424
1433
  // regexp 语法
1425
- let textMatch = selector.match(/:regexp\(("|')(.*)("|')\)$/i);
1434
+ const textMatch = selector.match(/:regexp\(("|')(.*)("|')\)$/i);
1426
1435
  let pattern = textMatch[2];
1427
- let flagMatch = pattern.match(/("|'),[\s]*("|')([igm]{0,3})$/i);
1436
+ const flagMatch = pattern.match(/("|'),[\s]*("|')([igm]{0,3})$/i);
1428
1437
  let flags = "";
1429
1438
  if (flagMatch) {
1430
1439
  pattern = pattern.replace(/("|'),[\s]*("|')([igm]{0,3})$/gi, "");
1431
1440
  flags = flagMatch[3];
1432
1441
  }
1433
- let regexp = new RegExp(pattern, flags);
1442
+ const regexp = new RegExp(pattern, flags);
1434
1443
  selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
1435
1444
  return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
1436
1445
  // @ts-ignore
@@ -1473,11 +1482,10 @@ class DOMUtilsEvent {
1473
1482
  selector = selector.replace(/:empty$/gi, "");
1474
1483
  return $el.matches(selector) && $el?.innerHTML?.trim() === "";
1475
1484
  }
1476
- else if (selector.match(/[^\s]{1}:contains\("(.*)"\)$/i) ||
1477
- selector.match(/[^\s]{1}:contains\('(.*)'\)$/i)) {
1485
+ else if (selector.match(/[^\s]{1}:contains\("(.*)"\)$/i) || selector.match(/[^\s]{1}:contains\('(.*)'\)$/i)) {
1478
1486
  // contains 语法
1479
- let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
1480
- let text = textMatch[2];
1487
+ const textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
1488
+ const text = textMatch[2];
1481
1489
  selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
1482
1490
  // @ts-ignore
1483
1491
  let content = $el?.textContent || $el?.innerText;
@@ -1486,18 +1494,17 @@ class DOMUtilsEvent {
1486
1494
  }
1487
1495
  return $el.matches(selector) && content?.includes(text);
1488
1496
  }
1489
- else if (selector.match(/[^\s]{1}:regexp\("(.*)"\)$/i) ||
1490
- selector.match(/[^\s]{1}:regexp\('(.*)'\)$/i)) {
1497
+ else if (selector.match(/[^\s]{1}:regexp\("(.*)"\)$/i) || selector.match(/[^\s]{1}:regexp\('(.*)'\)$/i)) {
1491
1498
  // regexp 语法
1492
- let textMatch = selector.match(/:regexp\(("|')(.*)("|')\)$/i);
1499
+ const textMatch = selector.match(/:regexp\(("|')(.*)("|')\)$/i);
1493
1500
  let pattern = textMatch[2];
1494
- let flagMatch = pattern.match(/("|'),[\s]*("|')([igm]{0,3})$/i);
1501
+ const flagMatch = pattern.match(/("|'),[\s]*("|')([igm]{0,3})$/i);
1495
1502
  let flags = "";
1496
1503
  if (flagMatch) {
1497
1504
  pattern = pattern.replace(/("|'),[\s]*("|')([igm]{0,3})$/gi, "");
1498
1505
  flags = flagMatch[3];
1499
1506
  }
1500
- let regexp = new RegExp(pattern, flags);
1507
+ const regexp = new RegExp(pattern, flags);
1501
1508
  selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
1502
1509
  // @ts-ignore
1503
1510
  let content = $el?.textContent || $el?.innerText;
@@ -1516,45 +1523,43 @@ class DOMUtilsEvent {
1516
1523
  if (selector.match(/[^\s]{1}:empty$/gi)) {
1517
1524
  // empty 语法
1518
1525
  selector = selector.replace(/:empty$/gi, "");
1519
- let $closest = $el?.closest(selector);
1526
+ const $closest = $el?.closest(selector);
1520
1527
  if ($closest && $closest?.innerHTML?.trim() === "") {
1521
1528
  return $closest;
1522
1529
  }
1523
1530
  return null;
1524
1531
  }
1525
- else if (selector.match(/[^\s]{1}:contains\("(.*)"\)$/i) ||
1526
- selector.match(/[^\s]{1}:contains\('(.*)'\)$/i)) {
1532
+ else if (selector.match(/[^\s]{1}:contains\("(.*)"\)$/i) || selector.match(/[^\s]{1}:contains\('(.*)'\)$/i)) {
1527
1533
  // contains 语法
1528
- let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
1529
- let text = textMatch[2];
1534
+ const textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
1535
+ const text = textMatch[2];
1530
1536
  selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
1531
- let $closest = $el?.closest(selector);
1537
+ const $closest = $el?.closest(selector);
1532
1538
  if ($closest) {
1533
1539
  // @ts-ignore
1534
- let content = $el?.textContent || $el?.innerText;
1540
+ const content = $el?.textContent || $el?.innerText;
1535
1541
  if (typeof content === "string" && content.includes(text)) {
1536
1542
  return $closest;
1537
1543
  }
1538
1544
  }
1539
1545
  return null;
1540
1546
  }
1541
- else if (selector.match(/[^\s]{1}:regexp\("(.*)"\)$/i) ||
1542
- selector.match(/[^\s]{1}:regexp\('(.*)'\)$/i)) {
1547
+ else if (selector.match(/[^\s]{1}:regexp\("(.*)"\)$/i) || selector.match(/[^\s]{1}:regexp\('(.*)'\)$/i)) {
1543
1548
  // regexp 语法
1544
- let textMatch = selector.match(/:regexp\(("|')(.*)("|')\)$/i);
1549
+ const textMatch = selector.match(/:regexp\(("|')(.*)("|')\)$/i);
1545
1550
  let pattern = textMatch[2];
1546
- let flagMatch = pattern.match(/("|'),[\s]*("|')([igm]{0,3})$/i);
1551
+ const flagMatch = pattern.match(/("|'),[\s]*("|')([igm]{0,3})$/i);
1547
1552
  let flags = "";
1548
1553
  if (flagMatch) {
1549
1554
  pattern = pattern.replace(/("|'),[\s]*("|')([igm]{0,3})$/gi, "");
1550
1555
  flags = flagMatch[3];
1551
1556
  }
1552
- let regexp = new RegExp(pattern, flags);
1557
+ const regexp = new RegExp(pattern, flags);
1553
1558
  selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
1554
- let $closest = $el?.closest(selector);
1559
+ const $closest = $el?.closest(selector);
1555
1560
  if ($closest) {
1556
1561
  // @ts-ignore
1557
- let content = $el?.textContent || $el?.innerText;
1562
+ const content = $el?.textContent || $el?.innerText;
1558
1563
  if (typeof content === "string" && content.match(regexp)) {
1559
1564
  return $closest;
1560
1565
  }
@@ -1563,20 +1568,22 @@ class DOMUtilsEvent {
1563
1568
  }
1564
1569
  else {
1565
1570
  // 普通语法
1566
- let $closest = $el?.closest(selector);
1571
+ const $closest = $el?.closest(selector);
1567
1572
  return $closest;
1568
1573
  }
1569
1574
  }
1570
1575
  }
1571
1576
 
1577
+ const version = "1.6.8";
1578
+
1572
1579
  class DOMUtils extends DOMUtilsEvent {
1573
1580
  constructor(option) {
1574
1581
  super(option);
1575
1582
  }
1576
1583
  /** 版本号 */
1577
- version = "2025.8.11";
1584
+ version = version;
1578
1585
  attr(element, attrName, attrValue) {
1579
- let DOMUtilsContext = this;
1586
+ const DOMUtilsContext = this;
1580
1587
  if (typeof element === "string") {
1581
1588
  element = DOMUtilsContext.selectorAll(element);
1582
1589
  }
@@ -1610,8 +1617,8 @@ class DOMUtils extends DOMUtilsEvent {
1610
1617
  property,
1611
1618
  /** 自定义属性 */
1612
1619
  attributes) {
1613
- let DOMUtilsContext = this;
1614
- let tempElement = DOMUtilsContext.windowApi.document.createElement(tagName);
1620
+ const DOMUtilsContext = this;
1621
+ const tempElement = DOMUtilsContext.windowApi.document.createElement(tagName);
1615
1622
  if (typeof property === "string") {
1616
1623
  DOMUtilsContext.html(tempElement, property);
1617
1624
  return tempElement;
@@ -1623,7 +1630,7 @@ class DOMUtils extends DOMUtilsEvent {
1623
1630
  attributes = {};
1624
1631
  }
1625
1632
  Object.keys(property).forEach((key) => {
1626
- let value = property[key];
1633
+ const value = property[key];
1627
1634
  if (key === "innerHTML") {
1628
1635
  DOMUtilsContext.html(tempElement, value);
1629
1636
  return;
@@ -1645,18 +1652,16 @@ class DOMUtils extends DOMUtilsEvent {
1645
1652
  return tempElement;
1646
1653
  }
1647
1654
  css(element, property, value) {
1648
- let DOMUtilsContext = this;
1655
+ const DOMUtilsContext = this;
1649
1656
  /**
1650
1657
  * 把纯数字没有px的加上
1651
1658
  */
1652
1659
  function handlePixe(propertyName, propertyValue) {
1653
- let allowAddPixe = ["width", "height", "top", "left", "right", "bottom", "font-size"];
1660
+ const allowAddPixe = ["width", "height", "top", "left", "right", "bottom", "font-size"];
1654
1661
  if (typeof propertyValue === "number") {
1655
1662
  propertyValue = propertyValue.toString();
1656
1663
  }
1657
- if (typeof propertyValue === "string" &&
1658
- allowAddPixe.includes(propertyName) &&
1659
- propertyValue.match(/[0-9]$/gi)) {
1664
+ if (typeof propertyValue === "string" && allowAddPixe.includes(propertyName) && propertyValue.match(/[0-9]$/gi)) {
1660
1665
  propertyValue = propertyValue + "px";
1661
1666
  }
1662
1667
  return propertyValue;
@@ -1688,10 +1693,9 @@ class DOMUtils extends DOMUtilsEvent {
1688
1693
  });
1689
1694
  return;
1690
1695
  }
1691
- else ;
1692
1696
  return;
1693
1697
  }
1694
- let setStyleProperty = (propertyName, propertyValue) => {
1698
+ const setStyleProperty = (propertyName, propertyValue) => {
1695
1699
  if (typeof propertyValue === "string" && propertyValue.trim().endsWith("!important")) {
1696
1700
  propertyValue = propertyValue
1697
1701
  .trim()
@@ -1713,8 +1717,8 @@ class DOMUtils extends DOMUtilsEvent {
1713
1717
  }
1714
1718
  }
1715
1719
  else if (typeof property === "object") {
1716
- for (let prop in property) {
1717
- let value = property[prop];
1720
+ for (const prop in property) {
1721
+ const value = property[prop];
1718
1722
  setStyleProperty(prop, value);
1719
1723
  }
1720
1724
  }
@@ -1724,7 +1728,7 @@ class DOMUtils extends DOMUtilsEvent {
1724
1728
  }
1725
1729
  }
1726
1730
  text(element, text) {
1727
- let DOMUtilsContext = this;
1731
+ const DOMUtilsContext = this;
1728
1732
  if (typeof element === "string") {
1729
1733
  element = DOMUtilsContext.selectorAll(element);
1730
1734
  }
@@ -1760,7 +1764,7 @@ class DOMUtils extends DOMUtilsEvent {
1760
1764
  }
1761
1765
  }
1762
1766
  html(element, html) {
1763
- let DOMUtilsContext = this;
1767
+ const DOMUtilsContext = this;
1764
1768
  if (typeof element === "string") {
1765
1769
  element = DOMUtilsContext.selectorAll(element);
1766
1770
  }
@@ -1798,19 +1802,19 @@ class DOMUtils extends DOMUtilsEvent {
1798
1802
  * 获取移动元素的transform偏移
1799
1803
  */
1800
1804
  getTransform(element, isShow = false) {
1801
- let DOMUtilsContext = this;
1805
+ const DOMUtilsContext = this;
1802
1806
  let transform_left = 0;
1803
1807
  let transform_top = 0;
1804
1808
  if (!(isShow || (!isShow && DOMUtilsCommonUtils.isShow(element)))) {
1805
1809
  /* 未显示 */
1806
- let { recovery } = DOMUtilsCommonUtils.showElement(element);
1807
- let transformInfo = DOMUtilsContext.getTransform(element, true);
1810
+ const { recovery } = DOMUtilsCommonUtils.showElement(element);
1811
+ const transformInfo = DOMUtilsContext.getTransform(element, true);
1808
1812
  recovery();
1809
1813
  return transformInfo;
1810
1814
  }
1811
- let elementTransform = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).transform;
1815
+ const elementTransform = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).transform;
1812
1816
  if (elementTransform != null && elementTransform !== "none" && elementTransform !== "") {
1813
- let elementTransformSplit = elementTransform.match(/\((.+)\)/)?.[1].split(",");
1817
+ const elementTransformSplit = elementTransform.match(/\((.+)\)/)?.[1].split(",");
1814
1818
  if (elementTransformSplit) {
1815
1819
  transform_left = Math.abs(parseInt(elementTransformSplit[4]));
1816
1820
  transform_top = Math.abs(parseInt(elementTransformSplit[5]));
@@ -1826,7 +1830,7 @@ class DOMUtils extends DOMUtilsEvent {
1826
1830
  };
1827
1831
  }
1828
1832
  val(element, value) {
1829
- let DOMUtilsContext = this;
1833
+ const DOMUtilsContext = this;
1830
1834
  if (typeof element === "string") {
1831
1835
  element = DOMUtilsContext.selectorAll(element);
1832
1836
  }
@@ -1866,7 +1870,7 @@ class DOMUtils extends DOMUtilsEvent {
1866
1870
  }
1867
1871
  }
1868
1872
  prop(element, propName, propValue) {
1869
- let DOMUtilsContext = this;
1873
+ const DOMUtilsContext = this;
1870
1874
  if (typeof element === "string") {
1871
1875
  element = DOMUtilsContext.selectorAll(element);
1872
1876
  }
@@ -1908,7 +1912,7 @@ class DOMUtils extends DOMUtilsEvent {
1908
1912
  * DOMUtils.removeAttr("a.xx","data-value")
1909
1913
  * */
1910
1914
  removeAttr(element, attrName) {
1911
- let DOMUtilsContext = this;
1915
+ const DOMUtilsContext = this;
1912
1916
  if (typeof element === "string") {
1913
1917
  element = DOMUtilsContext.selectorAll(element);
1914
1918
  }
@@ -1934,7 +1938,7 @@ class DOMUtils extends DOMUtilsEvent {
1934
1938
  * DOMUtils.removeClass("a.xx","xx")
1935
1939
  */
1936
1940
  removeClass(element, className) {
1937
- let DOMUtilsContext = this;
1941
+ const DOMUtilsContext = this;
1938
1942
  if (typeof element === "string") {
1939
1943
  element = DOMUtilsContext.selectorAll(element);
1940
1944
  }
@@ -1971,7 +1975,7 @@ class DOMUtils extends DOMUtilsEvent {
1971
1975
  * DOMUtils.removeProp("a.xx","href")
1972
1976
  * */
1973
1977
  removeProp(element, propName) {
1974
- let DOMUtilsContext = this;
1978
+ const DOMUtilsContext = this;
1975
1979
  if (typeof element === "string") {
1976
1980
  element = DOMUtilsContext.selectorAll(element);
1977
1981
  }
@@ -1997,7 +2001,7 @@ class DOMUtils extends DOMUtilsEvent {
1997
2001
  * DOMUtils.replaceWith("a.xx",'<b class="xx"></b>')
1998
2002
  */
1999
2003
  replaceWith(element, newElement) {
2000
- let DOMUtilsContext = this;
2004
+ const DOMUtilsContext = this;
2001
2005
  if (typeof element === "string") {
2002
2006
  element = DOMUtilsContext.selectorAll(element);
2003
2007
  }
@@ -2014,7 +2018,7 @@ class DOMUtils extends DOMUtilsEvent {
2014
2018
  if (typeof newElement === "string") {
2015
2019
  newElement = DOMUtilsContext.parseHTML(newElement, false, false);
2016
2020
  }
2017
- let $parent = element.parentElement;
2021
+ const $parent = element.parentElement;
2018
2022
  if ($parent) {
2019
2023
  $parent.replaceChild(newElement, element);
2020
2024
  }
@@ -2033,7 +2037,7 @@ class DOMUtils extends DOMUtilsEvent {
2033
2037
  * DOMUtils.addClass("a.xx","_vue_")
2034
2038
  * */
2035
2039
  addClass(element, className) {
2036
- let DOMUtilsContext = this;
2040
+ const DOMUtilsContext = this;
2037
2041
  if (typeof element === "string") {
2038
2042
  element = DOMUtilsContext.selectorAll(element);
2039
2043
  }
@@ -2063,7 +2067,7 @@ class DOMUtils extends DOMUtilsEvent {
2063
2067
  * @param className
2064
2068
  */
2065
2069
  hasClass(element, className) {
2066
- let DOMUtilsContext = this;
2070
+ const DOMUtilsContext = this;
2067
2071
  if (typeof element === "string") {
2068
2072
  element = DOMUtilsContext.selectorAll(element);
2069
2073
  }
@@ -2102,7 +2106,7 @@ class DOMUtils extends DOMUtilsEvent {
2102
2106
  * DOMUtils.append("a.xx","'<b class="xx"></b>")
2103
2107
  * */
2104
2108
  append(element, content) {
2105
- let DOMUtilsContext = this;
2109
+ const DOMUtilsContext = this;
2106
2110
  if (typeof element === "string") {
2107
2111
  element = DOMUtilsContext.selectorAll(element);
2108
2112
  }
@@ -2134,7 +2138,7 @@ class DOMUtils extends DOMUtilsEvent {
2134
2138
  }
2135
2139
  if (Array.isArray(content) || content instanceof NodeList) {
2136
2140
  /* 数组 */
2137
- let fragment = DOMUtilsContext.windowApi.document.createDocumentFragment();
2141
+ const fragment = DOMUtilsContext.windowApi.document.createDocumentFragment();
2138
2142
  content.forEach((ele) => {
2139
2143
  if (typeof ele === "string") {
2140
2144
  // 转为元素
@@ -2158,7 +2162,7 @@ class DOMUtils extends DOMUtilsEvent {
2158
2162
  * DOMUtils.prepend("a.xx","'<b class="xx"></b>")
2159
2163
  * */
2160
2164
  prepend(element, content) {
2161
- let DOMUtilsContext = this;
2165
+ const DOMUtilsContext = this;
2162
2166
  if (typeof element === "string") {
2163
2167
  element = DOMUtilsContext.selectorAll(element);
2164
2168
  }
@@ -2182,12 +2186,12 @@ class DOMUtils extends DOMUtilsEvent {
2182
2186
  }
2183
2187
  }
2184
2188
  else {
2185
- let $firstChild = element.firstChild;
2189
+ const $firstChild = element.firstChild;
2186
2190
  if ($firstChild == null) {
2187
2191
  element.prepend(content);
2188
2192
  }
2189
2193
  else {
2190
- element.insertBefore(content, element.firstChild);
2194
+ element.insertBefore(content, $firstChild);
2191
2195
  }
2192
2196
  }
2193
2197
  }
@@ -2201,7 +2205,7 @@ class DOMUtils extends DOMUtilsEvent {
2201
2205
  * DOMUtils.after("a.xx","'<b class="xx"></b>")
2202
2206
  * */
2203
2207
  after(element, content) {
2204
- let DOMUtilsContext = this;
2208
+ const DOMUtilsContext = this;
2205
2209
  if (typeof element === "string") {
2206
2210
  element = DOMUtilsContext.selectorAll(element);
2207
2211
  }
@@ -2219,14 +2223,14 @@ class DOMUtils extends DOMUtilsEvent {
2219
2223
  element.insertAdjacentHTML("afterend", DOMUtilsCommonUtils.getSafeHTML(content));
2220
2224
  }
2221
2225
  else {
2222
- let $parent = element.parentElement;
2223
- let $nextSlibling = element.nextSibling;
2226
+ const $parent = element.parentElement;
2227
+ const $nextSlibling = element.nextSibling;
2224
2228
  if (!$parent || $nextSlibling) {
2225
2229
  // 任意一个不行
2226
2230
  element.after(content);
2227
2231
  }
2228
2232
  else {
2229
- element.parentElement.insertBefore(content, element.nextSibling);
2233
+ $parent.insertBefore(content, $nextSlibling);
2230
2234
  }
2231
2235
  }
2232
2236
  }
@@ -2240,7 +2244,7 @@ class DOMUtils extends DOMUtilsEvent {
2240
2244
  * DOMUtils.before("a.xx","'<b class="xx"></b>")
2241
2245
  * */
2242
2246
  before(element, content) {
2243
- let DOMUtilsContext = this;
2247
+ const DOMUtilsContext = this;
2244
2248
  if (typeof element === "string") {
2245
2249
  element = DOMUtilsContext.selectorAll(element);
2246
2250
  }
@@ -2258,7 +2262,7 @@ class DOMUtils extends DOMUtilsEvent {
2258
2262
  element.insertAdjacentHTML("beforebegin", DOMUtilsCommonUtils.getSafeHTML(content));
2259
2263
  }
2260
2264
  else {
2261
- let $parent = element.parentElement;
2265
+ const $parent = element.parentElement;
2262
2266
  if (!$parent) {
2263
2267
  element.before(content);
2264
2268
  }
@@ -2277,7 +2281,7 @@ class DOMUtils extends DOMUtilsEvent {
2277
2281
  * DOMUtils.remove("a.xx")
2278
2282
  * */
2279
2283
  remove(element) {
2280
- let DOMUtilsContext = this;
2284
+ const DOMUtilsContext = this;
2281
2285
  if (typeof element === "string") {
2282
2286
  element = DOMUtilsContext.selectorAll(element);
2283
2287
  }
@@ -2309,7 +2313,7 @@ class DOMUtils extends DOMUtilsEvent {
2309
2313
  * DOMUtils.empty("a.xx")
2310
2314
  * */
2311
2315
  empty(element) {
2312
- let DOMUtilsContext = this;
2316
+ const DOMUtilsContext = this;
2313
2317
  if (typeof element === "string") {
2314
2318
  element = DOMUtilsContext.selectorAll(element);
2315
2319
  }
@@ -2340,14 +2344,14 @@ class DOMUtils extends DOMUtilsEvent {
2340
2344
  * > 0
2341
2345
  */
2342
2346
  offset(element) {
2343
- let DOMUtilsContext = this;
2347
+ const DOMUtilsContext = this;
2344
2348
  if (typeof element === "string") {
2345
2349
  element = DOMUtilsContext.selector(element);
2346
2350
  }
2347
2351
  if (element == null) {
2348
2352
  return;
2349
2353
  }
2350
- let rect = element.getBoundingClientRect();
2354
+ const rect = element.getBoundingClientRect();
2351
2355
  return {
2352
2356
  /** y轴偏移 */
2353
2357
  top: rect.top + DOMUtilsContext.windowApi.globalThis.scrollY,
@@ -2356,14 +2360,10 @@ class DOMUtils extends DOMUtilsEvent {
2356
2360
  };
2357
2361
  }
2358
2362
  width(element, isShow = false) {
2359
- let DOMUtilsContext = this;
2363
+ const DOMUtilsContext = this;
2360
2364
  if (typeof element === "string") {
2361
2365
  element = DOMUtilsContext.selector(element);
2362
2366
  }
2363
- if (element == null) {
2364
- // @ts-ignore
2365
- return;
2366
- }
2367
2367
  if (DOMUtilsCommonUtils.isWin(element)) {
2368
2368
  return DOMUtilsContext.windowApi.window.document.documentElement.clientWidth;
2369
2369
  }
@@ -2382,11 +2382,11 @@ class DOMUtils extends DOMUtilsEvent {
2382
2382
  }
2383
2383
  /* 如果从css里获取到的值不是大于0 可能是auto 则通过offsetWidth来进行计算 */
2384
2384
  if (element.offsetWidth > 0) {
2385
- let borderLeftWidth = DOMUtilsCommonUtils.getStyleValue(element, "borderLeftWidth");
2386
- let borderRightWidth = DOMUtilsCommonUtils.getStyleValue(element, "borderRightWidth");
2387
- let paddingLeft = DOMUtilsCommonUtils.getStyleValue(element, "paddingLeft");
2388
- let paddingRight = DOMUtilsCommonUtils.getStyleValue(element, "paddingRight");
2389
- let backHeight = parseFloat(element.offsetWidth.toString()) -
2385
+ const borderLeftWidth = DOMUtilsCommonUtils.getStyleValue(element, "borderLeftWidth");
2386
+ const borderRightWidth = DOMUtilsCommonUtils.getStyleValue(element, "borderRightWidth");
2387
+ const paddingLeft = DOMUtilsCommonUtils.getStyleValue(element, "paddingLeft");
2388
+ const paddingRight = DOMUtilsCommonUtils.getStyleValue(element, "paddingRight");
2389
+ const backHeight = parseFloat(element.offsetWidth.toString()) -
2390
2390
  parseFloat(borderLeftWidth.toString()) -
2391
2391
  parseFloat(borderRightWidth.toString()) -
2392
2392
  parseFloat(paddingLeft.toString()) -
@@ -2398,24 +2398,20 @@ class DOMUtils extends DOMUtilsEvent {
2398
2398
  else {
2399
2399
  /* 未显示 */
2400
2400
  element = element;
2401
- let { recovery } = DOMUtilsCommonUtils.showElement(element);
2402
- let width = DOMUtilsContext.width(element, true);
2401
+ const { recovery } = DOMUtilsCommonUtils.showElement(element);
2402
+ const width = DOMUtilsContext.width(element, true);
2403
2403
  recovery();
2404
2404
  return width;
2405
2405
  }
2406
2406
  }
2407
2407
  height(element, isShow = false) {
2408
- let DOMUtilsContext = this;
2408
+ const DOMUtilsContext = this;
2409
2409
  if (DOMUtilsCommonUtils.isWin(element)) {
2410
2410
  return DOMUtilsContext.windowApi.window.document.documentElement.clientHeight;
2411
2411
  }
2412
2412
  if (typeof element === "string") {
2413
2413
  element = DOMUtilsContext.selector(element);
2414
2414
  }
2415
- if (element == null) {
2416
- // @ts-ignore
2417
- return;
2418
- }
2419
2415
  if (element.nodeType === 9) {
2420
2416
  element = element;
2421
2417
  /* Document文档节点 */
@@ -2431,11 +2427,11 @@ class DOMUtils extends DOMUtilsEvent {
2431
2427
  }
2432
2428
  /* 如果从css里获取到的值不是大于0 可能是auto 则通过offsetHeight来进行计算 */
2433
2429
  if (element.offsetHeight > 0) {
2434
- let borderTopWidth = DOMUtilsCommonUtils.getStyleValue(element, "borderTopWidth");
2435
- let borderBottomWidth = DOMUtilsCommonUtils.getStyleValue(element, "borderBottomWidth");
2436
- let paddingTop = DOMUtilsCommonUtils.getStyleValue(element, "paddingTop");
2437
- let paddingBottom = DOMUtilsCommonUtils.getStyleValue(element, "paddingBottom");
2438
- let backHeight = parseFloat(element.offsetHeight.toString()) -
2430
+ const borderTopWidth = DOMUtilsCommonUtils.getStyleValue(element, "borderTopWidth");
2431
+ const borderBottomWidth = DOMUtilsCommonUtils.getStyleValue(element, "borderBottomWidth");
2432
+ const paddingTop = DOMUtilsCommonUtils.getStyleValue(element, "paddingTop");
2433
+ const paddingBottom = DOMUtilsCommonUtils.getStyleValue(element, "paddingBottom");
2434
+ const backHeight = parseFloat(element.offsetHeight.toString()) -
2439
2435
  parseFloat(borderTopWidth.toString()) -
2440
2436
  parseFloat(borderBottomWidth.toString()) -
2441
2437
  parseFloat(paddingTop.toString()) -
@@ -2447,60 +2443,52 @@ class DOMUtils extends DOMUtilsEvent {
2447
2443
  else {
2448
2444
  /* 未显示 */
2449
2445
  element = element;
2450
- let { recovery } = DOMUtilsCommonUtils.showElement(element);
2451
- let height = DOMUtilsContext.height(element, true);
2446
+ const { recovery } = DOMUtilsCommonUtils.showElement(element);
2447
+ const height = DOMUtilsContext.height(element, true);
2452
2448
  recovery();
2453
2449
  return height;
2454
2450
  }
2455
2451
  }
2456
2452
  outerWidth(element, isShow = false) {
2457
- let DOMUtilsContext = this;
2453
+ const DOMUtilsContext = this;
2458
2454
  if (DOMUtilsCommonUtils.isWin(element)) {
2459
2455
  return DOMUtilsContext.windowApi.window.innerWidth;
2460
2456
  }
2461
2457
  if (typeof element === "string") {
2462
2458
  element = DOMUtilsContext.selector(element);
2463
2459
  }
2464
- if (element == null) {
2465
- // @ts-ignore
2466
- return;
2467
- }
2468
2460
  element = element;
2469
2461
  if (isShow || (!isShow && DOMUtilsCommonUtils.isShow(element))) {
2470
- let style = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element, null);
2471
- let marginLeft = DOMUtilsCommonUtils.getStyleValue(style, "marginLeft");
2472
- let marginRight = DOMUtilsCommonUtils.getStyleValue(style, "marginRight");
2462
+ const style = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element, null);
2463
+ const marginLeft = DOMUtilsCommonUtils.getStyleValue(style, "marginLeft");
2464
+ const marginRight = DOMUtilsCommonUtils.getStyleValue(style, "marginRight");
2473
2465
  return element.offsetWidth + marginLeft + marginRight;
2474
2466
  }
2475
2467
  else {
2476
- let { recovery } = DOMUtilsCommonUtils.showElement(element);
2477
- let outerWidth = DOMUtilsContext.outerWidth(element, true);
2468
+ const { recovery } = DOMUtilsCommonUtils.showElement(element);
2469
+ const outerWidth = DOMUtilsContext.outerWidth(element, true);
2478
2470
  recovery();
2479
2471
  return outerWidth;
2480
2472
  }
2481
2473
  }
2482
2474
  outerHeight(element, isShow = false) {
2483
- let DOMUtilsContext = this;
2475
+ const DOMUtilsContext = this;
2484
2476
  if (DOMUtilsCommonUtils.isWin(element)) {
2485
2477
  return DOMUtilsContext.windowApi.window.innerHeight;
2486
2478
  }
2487
2479
  if (typeof element === "string") {
2488
2480
  element = DOMUtilsContext.selector(element);
2489
2481
  }
2490
- if (element == null) {
2491
- // @ts-ignore
2492
- return;
2493
- }
2494
2482
  element = element;
2495
2483
  if (isShow || (!isShow && DOMUtilsCommonUtils.isShow(element))) {
2496
- let style = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element, null);
2497
- let marginTop = DOMUtilsCommonUtils.getStyleValue(style, "marginTop");
2498
- let marginBottom = DOMUtilsCommonUtils.getStyleValue(style, "marginBottom");
2484
+ const style = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element, null);
2485
+ const marginTop = DOMUtilsCommonUtils.getStyleValue(style, "marginTop");
2486
+ const marginBottom = DOMUtilsCommonUtils.getStyleValue(style, "marginBottom");
2499
2487
  return element.offsetHeight + marginTop + marginBottom;
2500
2488
  }
2501
2489
  else {
2502
- let { recovery } = DOMUtilsCommonUtils.showElement(element);
2503
- let outerHeight = DOMUtilsContext.outerHeight(element, true);
2490
+ const { recovery } = DOMUtilsCommonUtils.showElement(element);
2491
+ const outerHeight = DOMUtilsContext.outerHeight(element, true);
2504
2492
  recovery();
2505
2493
  return outerHeight;
2506
2494
  }
@@ -2518,7 +2506,7 @@ class DOMUtils extends DOMUtilsEvent {
2518
2506
  * })
2519
2507
  */
2520
2508
  animate(element, styles, duration = 1000, callback = null) {
2521
- let DOMUtilsContext = this;
2509
+ const DOMUtilsContext = this;
2522
2510
  if (typeof element === "string") {
2523
2511
  element = DOMUtilsContext.selectorAll(element);
2524
2512
  }
@@ -2544,21 +2532,20 @@ class DOMUtils extends DOMUtilsEvent {
2544
2532
  if (Object.keys(styles).length === 0) {
2545
2533
  throw new Error("styles must contain at least one property");
2546
2534
  }
2547
- let start = performance.now();
2548
- let from = {};
2549
- let to = {};
2550
- for (let prop in styles) {
2551
- from[prop] =
2552
- element.style[prop] || DOMUtilsContext.windowApi.globalThis.getComputedStyle(element)[prop];
2535
+ const start = performance.now();
2536
+ const from = {};
2537
+ const to = {};
2538
+ for (const prop in styles) {
2539
+ from[prop] = element.style[prop] || DOMUtilsContext.windowApi.globalThis.getComputedStyle(element)[prop];
2553
2540
  to[prop] = styles[prop];
2554
2541
  }
2555
- let timer = DOMUtilsCommonUtils.setInterval(function () {
2556
- let timePassed = performance.now() - start;
2542
+ const timer = DOMUtilsCommonUtils.setInterval(function () {
2543
+ const timePassed = performance.now() - start;
2557
2544
  let progress = timePassed / duration;
2558
2545
  if (progress > 1) {
2559
2546
  progress = 1;
2560
2547
  }
2561
- for (let prop in styles) {
2548
+ for (const prop in styles) {
2562
2549
  element.style[prop] = from[prop] + (to[prop] - from[prop]) * progress + "px";
2563
2550
  }
2564
2551
  if (progress === 1) {
@@ -2578,7 +2565,7 @@ class DOMUtils extends DOMUtilsEvent {
2578
2565
  * DOMUtils.wrap(document.querySelector("a.xx"),"<div></div>")
2579
2566
  */
2580
2567
  wrap(element, wrapperHTML) {
2581
- let DOMUtilsContext = this;
2568
+ const DOMUtilsContext = this;
2582
2569
  if (typeof element === "string") {
2583
2570
  element = DOMUtilsContext.selectorAll(element);
2584
2571
  }
@@ -2594,17 +2581,17 @@ class DOMUtils extends DOMUtilsEvent {
2594
2581
  }
2595
2582
  element = element;
2596
2583
  // 创建一个新的div元素,并将wrapperHTML作为其innerHTML
2597
- let wrapper = DOMUtilsContext.windowApi.document.createElement("div");
2584
+ const wrapper = DOMUtilsContext.windowApi.document.createElement("div");
2598
2585
  DOMUtilsContext.html(wrapper, wrapperHTML);
2599
- let wrapperFirstChild = wrapper.firstChild;
2586
+ const wrapperFirstChild = wrapper.firstChild;
2600
2587
  // 将要包裹的元素插入目标元素前面
2601
- let parentElement = element.parentElement;
2588
+ const parentElement = element.parentElement;
2602
2589
  parentElement.insertBefore(wrapperFirstChild, element);
2603
2590
  // 将要包裹的元素移动到wrapper中
2604
2591
  wrapperFirstChild.appendChild(element);
2605
2592
  }
2606
2593
  prev(element) {
2607
- let DOMUtilsContext = this;
2594
+ const DOMUtilsContext = this;
2608
2595
  if (typeof element === "string") {
2609
2596
  element = DOMUtilsContext.selector(element);
2610
2597
  }
@@ -2614,7 +2601,7 @@ class DOMUtils extends DOMUtilsEvent {
2614
2601
  return element.previousElementSibling;
2615
2602
  }
2616
2603
  next(element) {
2617
- let DOMUtilsContext = this;
2604
+ const DOMUtilsContext = this;
2618
2605
  if (typeof element === "string") {
2619
2606
  element = DOMUtilsContext.selector(element);
2620
2607
  }
@@ -2629,7 +2616,7 @@ class DOMUtils extends DOMUtilsEvent {
2629
2616
  * let DOMUtils = window.DOMUtils.noConflict()
2630
2617
  */
2631
2618
  noConflict() {
2632
- let DOMUtilsContext = this;
2619
+ const DOMUtilsContext = this;
2633
2620
  if (DOMUtilsContext.windowApi.window.DOMUtils) {
2634
2621
  DOMUtilsCommonUtils.delete(window, "DOMUtils");
2635
2622
  }
@@ -2637,7 +2624,7 @@ class DOMUtils extends DOMUtilsEvent {
2637
2624
  return this;
2638
2625
  }
2639
2626
  siblings(element) {
2640
- let DOMUtilsContext = this;
2627
+ const DOMUtilsContext = this;
2641
2628
  if (typeof element === "string") {
2642
2629
  element = DOMUtilsContext.selector(element);
2643
2630
  }
@@ -2657,7 +2644,7 @@ class DOMUtils extends DOMUtilsEvent {
2657
2644
  * > <div ...>....</div>
2658
2645
  */
2659
2646
  parent(element) {
2660
- let DOMUtilsContext = this;
2647
+ const DOMUtilsContext = this;
2661
2648
  if (typeof element === "string") {
2662
2649
  element = DOMUtilsContext.selector(element);
2663
2650
  }
@@ -2665,7 +2652,7 @@ class DOMUtils extends DOMUtilsEvent {
2665
2652
  return;
2666
2653
  }
2667
2654
  if (DOMUtilsCommonUtils.isNodeList(element)) {
2668
- let resultArray = [];
2655
+ const resultArray = [];
2669
2656
  element.forEach(($ele) => {
2670
2657
  resultArray.push(DOMUtilsContext.parent($ele));
2671
2658
  });
@@ -2676,11 +2663,11 @@ class DOMUtils extends DOMUtilsEvent {
2676
2663
  }
2677
2664
  }
2678
2665
  parseHTML(html, useParser = false, isComplete = false) {
2679
- let DOMUtilsContext = this;
2666
+ const DOMUtilsContext = this;
2680
2667
  // 去除html前后的空格
2681
2668
  html = html.trim();
2682
2669
  function parseHTMLByDOMParser() {
2683
- let parser = new DOMParser();
2670
+ const parser = new DOMParser();
2684
2671
  if (isComplete) {
2685
2672
  return parser.parseFromString(html, "text/html");
2686
2673
  }
@@ -2689,7 +2676,7 @@ class DOMUtils extends DOMUtilsEvent {
2689
2676
  }
2690
2677
  }
2691
2678
  function parseHTMLByCreateDom() {
2692
- let tempDIV = DOMUtilsContext.windowApi.document.createElement("div");
2679
+ const tempDIV = DOMUtilsContext.windowApi.document.createElement("div");
2693
2680
  DOMUtilsContext.html(tempDIV, html);
2694
2681
  if (isComplete) {
2695
2682
  return tempDIV;
@@ -2714,7 +2701,7 @@ class DOMUtils extends DOMUtilsEvent {
2714
2701
  */
2715
2702
  serialize($form) {
2716
2703
  const elements = $form.elements;
2717
- let serializedArray = [];
2704
+ const serializedArray = [];
2718
2705
  for (let i = 0; i < elements.length; i++) {
2719
2706
  const element = elements[i];
2720
2707
  if (element.name &&
@@ -2753,7 +2740,7 @@ class DOMUtils extends DOMUtilsEvent {
2753
2740
  * DOMUtils.show("a.xx")
2754
2741
  */
2755
2742
  show(target, checkVisiblie = true) {
2756
- let DOMUtilsContext = this;
2743
+ const DOMUtilsContext = this;
2757
2744
  if (target == null) {
2758
2745
  return;
2759
2746
  }
@@ -2790,7 +2777,7 @@ class DOMUtils extends DOMUtilsEvent {
2790
2777
  * DOMUtils.hide("a.xx")
2791
2778
  */
2792
2779
  hide(target, checkVisiblie = true) {
2793
- let DOMUtilsContext = this;
2780
+ const DOMUtilsContext = this;
2794
2781
  if (target == null) {
2795
2782
  return;
2796
2783
  }
@@ -2832,7 +2819,7 @@ class DOMUtils extends DOMUtilsEvent {
2832
2819
  if (element == null) {
2833
2820
  return;
2834
2821
  }
2835
- let DOMUtilsContext = this;
2822
+ const DOMUtilsContext = this;
2836
2823
  if (typeof element === "string") {
2837
2824
  element = DOMUtilsContext.selectorAll(element);
2838
2825
  }
@@ -2850,7 +2837,7 @@ class DOMUtils extends DOMUtilsEvent {
2850
2837
  function step(timestamp) {
2851
2838
  if (!start)
2852
2839
  start = timestamp;
2853
- let progress = timestamp - start;
2840
+ const progress = timestamp - start;
2854
2841
  element = element;
2855
2842
  element.style.opacity = Math.min(progress / duration, 1).toString();
2856
2843
  if (progress < duration) {
@@ -2880,7 +2867,7 @@ class DOMUtils extends DOMUtilsEvent {
2880
2867
  * })
2881
2868
  */
2882
2869
  fadeOut(element, duration = 400, callback) {
2883
- let DOMUtilsContext = this;
2870
+ const DOMUtilsContext = this;
2884
2871
  if (element == null) {
2885
2872
  return;
2886
2873
  }
@@ -2900,7 +2887,7 @@ class DOMUtils extends DOMUtilsEvent {
2900
2887
  function step(timestamp) {
2901
2888
  if (!start)
2902
2889
  start = timestamp;
2903
- let progress = timestamp - start;
2890
+ const progress = timestamp - start;
2904
2891
  element = element;
2905
2892
  element.style.opacity = Math.max(1 - progress / duration, 0).toString();
2906
2893
  if (progress < duration) {
@@ -2926,7 +2913,7 @@ class DOMUtils extends DOMUtilsEvent {
2926
2913
  * DOMUtils.toggle("a.xx")
2927
2914
  */
2928
2915
  toggle(element, checkVisiblie) {
2929
- let DOMUtilsContext = this;
2916
+ const DOMUtilsContext = this;
2930
2917
  if (typeof element === "string") {
2931
2918
  element = DOMUtilsContext.selectorAll(element);
2932
2919
  }
@@ -2964,7 +2951,7 @@ class DOMUtils extends DOMUtilsEvent {
2964
2951
  * DOMUtils.getTextBoundingRect(document.querySelector("input"));
2965
2952
  */
2966
2953
  getTextBoundingRect($input, selectionStart, selectionEnd) {
2967
- let DOMUtilsContext = this;
2954
+ const DOMUtilsContext = this;
2968
2955
  // Basic parameter validation
2969
2956
  if (!$input || !("value" in $input))
2970
2957
  return $input;
@@ -2993,18 +2980,20 @@ class DOMUtils extends DOMUtilsEvent {
2993
2980
  else
2994
2981
  selectionEnd = Math.min($input.value.length, selectionEnd);
2995
2982
  // If available (thus IE), use the createTextRange method
2996
- // @ts-ignore
2997
2983
  if (typeof $input.createTextRange == "function") {
2998
- let range = $input.createTextRange();
2984
+ const range = $input.createTextRange();
2999
2985
  range.collapse(true);
3000
2986
  range.moveStart("character", selectionStart);
3001
2987
  range.moveEnd("character", selectionEnd - selectionStart);
3002
2988
  return range.getBoundingClientRect();
3003
2989
  }
3004
2990
  // createTextRange is not supported, create a fake text range
3005
- let offset = getInputOffset(), topPos = offset.top, leftPos = offset.left, width = getInputCSS("width", true), height = getInputCSS("height", true);
2991
+ const offset = getInputOffset(), width = getInputCSS("width", true), height = getInputCSS("height", true);
2992
+ let topPos = offset.top;
2993
+ let leftPos = offset.left;
3006
2994
  // Styles to simulate a node in an input field
3007
- let cssDefaultStyles = "white-space:pre;padding:0;margin:0;", listOfModifiers = [
2995
+ let cssDefaultStyles = "white-space:pre;padding:0;margin:0;";
2996
+ const listOfModifiers = [
3008
2997
  "direction",
3009
2998
  "font-family",
3010
2999
  "font-size",
@@ -3026,16 +3015,15 @@ class DOMUtils extends DOMUtilsEvent {
3026
3015
  leftPos += getInputCSS("border-left-width", true);
3027
3016
  leftPos += 1; //Seems to be necessary
3028
3017
  for (let index = 0; index < listOfModifiers.length; index++) {
3029
- let property = listOfModifiers[index];
3030
- // @ts-ignore
3031
- cssDefaultStyles += property + ":" + getInputCSS(property) + ";";
3018
+ const property = listOfModifiers[index];
3019
+ cssDefaultStyles += property + ":" + getInputCSS(property, false) + ";";
3032
3020
  }
3033
3021
  // End of CSS variable checks
3034
3022
  // 不能为空,不然获取不到高度
3035
- let text = $input.value || "G", textLen = text.length, fakeClone = DOMUtilsContext.windowApi.document.createElement("div");
3023
+ const text = $input.value || "G", textLen = text.length, fakeClone = DOMUtilsContext.windowApi.document.createElement("div");
3036
3024
  if (selectionStart > 0)
3037
3025
  appendPart(0, selectionStart);
3038
- var fakeRange = appendPart(selectionStart, selectionEnd);
3026
+ const fakeRange = appendPart(selectionStart, selectionEnd);
3039
3027
  if (textLen > selectionEnd)
3040
3028
  appendPart(selectionEnd, textLen);
3041
3029
  // Styles to inherit the font styles of the element
@@ -3047,7 +3035,7 @@ class DOMUtils extends DOMUtilsEvent {
3047
3035
  fakeClone.style.width = width + "px";
3048
3036
  fakeClone.style.height = height + "px";
3049
3037
  DOMUtilsContext.windowApi.document.body.appendChild(fakeClone);
3050
- var returnValue = fakeRange.getBoundingClientRect(); //Get rect
3038
+ const returnValue = fakeRange.getBoundingClientRect(); //Get rect
3051
3039
  fakeClone?.parentNode?.removeChild(fakeClone); //Remove temp
3052
3040
  return returnValue;
3053
3041
  // Local functions for readability of the previous code
@@ -3058,7 +3046,7 @@ class DOMUtils extends DOMUtilsEvent {
3058
3046
  * @returns
3059
3047
  */
3060
3048
  function appendPart(start, end) {
3061
- var span = DOMUtilsContext.windowApi.document.createElement("span");
3049
+ const span = DOMUtilsContext.windowApi.document.createElement("span");
3062
3050
  span.style.cssText = cssDefaultStyles; //Force styles to prevent unexpected results
3063
3051
  span.textContent = text.substring(start, end);
3064
3052
  fakeClone.appendChild(span);
@@ -3066,13 +3054,13 @@ class DOMUtils extends DOMUtilsEvent {
3066
3054
  }
3067
3055
  // Computing offset position
3068
3056
  function getInputOffset() {
3069
- let body = DOMUtilsContext.windowApi.document.body, win = DOMUtilsContext.windowApi.document.defaultView, docElem = DOMUtilsContext.windowApi.document.documentElement, $box = DOMUtilsContext.windowApi.document.createElement("div");
3057
+ const body = DOMUtilsContext.windowApi.document.body, win = DOMUtilsContext.windowApi.document.defaultView, docElem = DOMUtilsContext.windowApi.document.documentElement, $box = DOMUtilsContext.windowApi.document.createElement("div");
3070
3058
  $box.style.paddingLeft = $box.style.width = "1px";
3071
3059
  body.appendChild($box);
3072
- var isBoxModel = $box.offsetWidth == 2;
3060
+ const isBoxModel = $box.offsetWidth == 2;
3073
3061
  body.removeChild($box);
3074
- let $boxRect = $input.getBoundingClientRect();
3075
- 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;
3062
+ const $boxRect = $input.getBoundingClientRect();
3063
+ 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;
3076
3064
  return {
3077
3065
  top: $boxRect.top + scrollTop - clientTop,
3078
3066
  left: $boxRect.left + scrollLeft - clientLeft,
@@ -3085,10 +3073,13 @@ class DOMUtils extends DOMUtilsEvent {
3085
3073
  * @returns
3086
3074
  */
3087
3075
  function getInputCSS(prop, isNumber) {
3088
- var val = DOMUtilsContext.windowApi.document
3089
- .defaultView.getComputedStyle($input, null)
3090
- .getPropertyValue(prop);
3091
- return isNumber ? parseFloat(val) : val;
3076
+ const val = DOMUtilsContext.windowApi.document.defaultView.getComputedStyle($input, null).getPropertyValue(prop);
3077
+ if (isNumber) {
3078
+ return parseFloat(val);
3079
+ }
3080
+ else {
3081
+ return val;
3082
+ }
3092
3083
  }
3093
3084
  }
3094
3085
  /** 获取 animationend 在各个浏览器的兼容名 */
@@ -3100,7 +3091,7 @@ class DOMUtils extends DOMUtilsEvent {
3100
3091
  return DOMUtilsCommonUtils.getTransitionEndNameList();
3101
3092
  }
3102
3093
  }
3103
- let domUtils = new DOMUtils();
3094
+ const domUtils = new DOMUtils();
3104
3095
 
3105
3096
  export { domUtils as default };
3106
3097
  //# sourceMappingURL=index.esm.js.map