@whitesev/domutils 1.5.11 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.amd.js +129 -75
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +129 -75
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +129 -75
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +129 -75
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +129 -75
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +129 -75
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/DOMUtils.d.ts +16 -12
- package/dist/types/src/DOMUtilsCommonUtils.d.ts +4 -0
- package/dist/types/src/DOMUtilsEvent.d.ts +18 -0
- package/dist/types/src/types/DOMUtilsEvent.d.ts +2 -1
- package/package.json +5 -3
- package/src/DOMUtils.ts +98 -254
- package/src/DOMUtilsCommonUtils.ts +9 -4
- package/src/DOMUtilsData.ts +1 -3
- package/src/DOMUtilsEvent.ts +121 -178
- package/src/types/DOMUtilsEvent.d.ts +2 -1
package/dist/index.amd.js
CHANGED
|
@@ -280,7 +280,7 @@ define((function () { 'use strict';
|
|
|
280
280
|
};
|
|
281
281
|
|
|
282
282
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
283
|
-
const worker = `(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),
|
|
283
|
+
const worker = `(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),l=t(c);e.addUniqueNumber=l,e.generateUniqueNumber=c}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,o=(e,t)=>Object.assign(new Error(e),{status:t}),s=t=>o('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),a=(t,r)=>async({data:{id:a,method:i,params:u}})=>{const c=r[i];try{if(void 0===c)throw(e=>o('The requested method called "'.concat(e,'" is not supported.'),n))(i);const r=void 0===u?c():c(u);if(void 0===r)throw(t=>o('The handler of the method called "'.concat(t,'" returned no required result.'),e))(i);const l=r instanceof Promise?await r:r;if(null===a){if(void 0!==l.result)throw s(i)}else{if(void 0===l.result)throw s(i);const{result:e,transferables:r=[]}=l;t.postMessage({id:a,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:a})}};var i=r(455);const u=new Map,c=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),o=(0,i.generateUniqueNumber)(u);return u.set(o,(()=>{n(),t.close(),u.delete(o)})),{result:o}},disconnect:({portId:e})=>{const r=u.get(e);if(void 0===r)throw(e=>o('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),t))(e);return r(),{result:null}},isSupported:async()=>{if(await new Promise((e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])}))){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),l=(e,t,r=()=>!0)=>{const n=c(l,t,r),o=a(e,n);return e.addEventListener("message",o),()=>e.removeEventListener("message",o)},d=(e,t)=>r=>{const n=t.get(r);if(void 0===n)return Promise.resolve(!1);const[o,s]=n;return e(o),t.delete(r),s(!1),Promise.resolve(!0)},f=(e,t,r,n)=>(o,s,a)=>{const i=o+s-t.timeOrigin,u=i-t.now();return new Promise((t=>{e.set(a,[r(n,u,i,e,t,a),t])}))},m=new Map,h=d(globalThis.clearTimeout,m),p=new Map,v=d(globalThis.clearTimeout,p),w=((e,t)=>{const r=(n,o,s,a)=>{const i=n-e.now();i>0?o.set(a,[t(r,i,n,o,s,a),s]):(o.delete(a),s(!0))};return r})(performance,globalThis.setTimeout),g=f(m,performance,globalThis.setTimeout,w),T=f(p,performance,globalThis.setTimeout,w);l(self,{clear:async({timerId:e,timerType:t})=>({result:await("interval"===t?h(e):v(e))}),set:async({delay:e,now:t,timerId:r,timerType:n})=>({result:await("interval"===n?g:T)(e,t,r)})})})()})();`; // tslint:disable-line:max-line-length
|
|
284
284
|
|
|
285
285
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
286
286
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -480,6 +480,14 @@ define((function () { 'use strict';
|
|
|
480
480
|
isNodeList($ele) {
|
|
481
481
|
return Array.isArray($ele) || $ele instanceof NodeList;
|
|
482
482
|
},
|
|
483
|
+
/** 获取 animationend 在各个浏览器的兼容名 */
|
|
484
|
+
getAnimationEndNameList() {
|
|
485
|
+
return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
|
|
486
|
+
},
|
|
487
|
+
/** 获取 transitionend 在各个浏览器的兼容名 */
|
|
488
|
+
getTransitionEndNameList() {
|
|
489
|
+
return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
|
|
490
|
+
},
|
|
483
491
|
};
|
|
484
492
|
|
|
485
493
|
/* 数据 */
|
|
@@ -602,8 +610,7 @@ define((function () { 'use strict';
|
|
|
602
610
|
: event.target;
|
|
603
611
|
let totalParent = elementItem;
|
|
604
612
|
if (DOMUtilsCommonUtils.isWin(totalParent)) {
|
|
605
|
-
if (totalParent ===
|
|
606
|
-
DOMUtilsContext.windowApi.document) {
|
|
613
|
+
if (totalParent === DOMUtilsContext.windowApi.document) {
|
|
607
614
|
totalParent = DOMUtilsContext.windowApi.document.documentElement;
|
|
608
615
|
}
|
|
609
616
|
}
|
|
@@ -671,8 +678,7 @@ define((function () { 'use strict';
|
|
|
671
678
|
if (typeof currentParam === "boolean") {
|
|
672
679
|
option.capture = currentParam;
|
|
673
680
|
}
|
|
674
|
-
else if (typeof currentParam === "object" &&
|
|
675
|
-
"capture" in currentParam) {
|
|
681
|
+
else if (typeof currentParam === "object" && "capture" in currentParam) {
|
|
676
682
|
option.capture = currentParam.capture;
|
|
677
683
|
}
|
|
678
684
|
return option;
|
|
@@ -734,8 +740,7 @@ define((function () { 'use strict';
|
|
|
734
740
|
// 目标函数、事件名
|
|
735
741
|
isRemoveAll = true;
|
|
736
742
|
}
|
|
737
|
-
else if ((args.length === 3 && typeof args[2] === "string") ||
|
|
738
|
-
Array.isArray(args[2])) {
|
|
743
|
+
else if ((args.length === 3 && typeof args[2] === "string") || Array.isArray(args[2])) {
|
|
739
744
|
// 目标函数、事件名、子元素选择器
|
|
740
745
|
isRemoveAll = true;
|
|
741
746
|
}
|
|
@@ -750,9 +755,7 @@ define((function () { 'use strict';
|
|
|
750
755
|
for (let index = 0; index < handlers.length; index++) {
|
|
751
756
|
let handler = handlers[index];
|
|
752
757
|
let flag = true;
|
|
753
|
-
if (flag &&
|
|
754
|
-
listenerCallBack &&
|
|
755
|
-
handler.originCallBack !== listenerCallBack) {
|
|
758
|
+
if (flag && listenerCallBack && handler.originCallBack !== listenerCallBack) {
|
|
756
759
|
// callback不同
|
|
757
760
|
flag = false;
|
|
758
761
|
}
|
|
@@ -812,9 +815,7 @@ define((function () { 'use strict';
|
|
|
812
815
|
return;
|
|
813
816
|
}
|
|
814
817
|
let elementEvents = elementItem[symbolEvents] || {};
|
|
815
|
-
let iterEventNameList = eventTypeList.length
|
|
816
|
-
? eventTypeList
|
|
817
|
-
: Object.keys(elementEvents);
|
|
818
|
+
let iterEventNameList = eventTypeList.length ? eventTypeList : Object.keys(elementEvents);
|
|
818
819
|
iterEventNameList.forEach((eventName) => {
|
|
819
820
|
let handlers = elementEvents[eventName];
|
|
820
821
|
if (!handlers) {
|
|
@@ -851,8 +852,7 @@ define((function () { 'use strict';
|
|
|
851
852
|
try {
|
|
852
853
|
if (DOMUtilsContext.windowApi.document.readyState === "complete" ||
|
|
853
854
|
(DOMUtilsContext.windowApi.document.readyState !== "loading" &&
|
|
854
|
-
!DOMUtilsContext.windowApi.document.documentElement
|
|
855
|
-
.doScroll)) {
|
|
855
|
+
!DOMUtilsContext.windowApi.document.documentElement.doScroll)) {
|
|
856
856
|
return true;
|
|
857
857
|
}
|
|
858
858
|
else {
|
|
@@ -1113,6 +1113,76 @@ define((function () { 'use strict';
|
|
|
1113
1113
|
DOMUtilsContext.on(element, "mouseenter", null, handler, option);
|
|
1114
1114
|
DOMUtilsContext.on(element, "mouseleave", null, handler, option);
|
|
1115
1115
|
}
|
|
1116
|
+
/**
|
|
1117
|
+
* 当动画结束时触发事件
|
|
1118
|
+
* @param element 监听的元素
|
|
1119
|
+
* @param handler 触发的回调函数
|
|
1120
|
+
* @param option 配置项,这里默认配置once为true
|
|
1121
|
+
*/
|
|
1122
|
+
animationend(element, handler, option) {
|
|
1123
|
+
let DOMUtilsContext = this;
|
|
1124
|
+
if (typeof element === "string") {
|
|
1125
|
+
element = DOMUtilsContext.selector(element);
|
|
1126
|
+
}
|
|
1127
|
+
if (element == null) {
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
if (DOMUtilsCommonUtils.isNodeList(element)) {
|
|
1131
|
+
// 设置
|
|
1132
|
+
element.forEach(($ele) => {
|
|
1133
|
+
DOMUtilsContext.animationend($ele, handler, option);
|
|
1134
|
+
});
|
|
1135
|
+
return;
|
|
1136
|
+
}
|
|
1137
|
+
const defaultOption = {
|
|
1138
|
+
once: true,
|
|
1139
|
+
};
|
|
1140
|
+
Object.assign(defaultOption, option || {});
|
|
1141
|
+
const eventNameList = DOMUtilsCommonUtils.getAnimationEndNameList();
|
|
1142
|
+
DOMUtilsContext.on(element, eventNameList, null, handler, defaultOption);
|
|
1143
|
+
if (!defaultOption.once) {
|
|
1144
|
+
return {
|
|
1145
|
+
off() {
|
|
1146
|
+
DOMUtilsContext.off(element, eventNameList, null, handler, defaultOption);
|
|
1147
|
+
},
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* 当过渡结束时触发事件
|
|
1153
|
+
* @param element 监听的元素
|
|
1154
|
+
* @param handler 触发的回调函数
|
|
1155
|
+
* @param option 配置项,这里默认配置once为true
|
|
1156
|
+
*/
|
|
1157
|
+
transitionend(element, handler, option) {
|
|
1158
|
+
let DOMUtilsContext = this;
|
|
1159
|
+
if (typeof element === "string") {
|
|
1160
|
+
element = DOMUtilsContext.selector(element);
|
|
1161
|
+
}
|
|
1162
|
+
if (element == null) {
|
|
1163
|
+
return;
|
|
1164
|
+
}
|
|
1165
|
+
if (DOMUtilsCommonUtils.isNodeList(element)) {
|
|
1166
|
+
// 设置
|
|
1167
|
+
element.forEach(($ele) => {
|
|
1168
|
+
DOMUtilsContext.transitionend($ele, handler, option);
|
|
1169
|
+
});
|
|
1170
|
+
return;
|
|
1171
|
+
}
|
|
1172
|
+
const defaultOption = {
|
|
1173
|
+
once: true,
|
|
1174
|
+
};
|
|
1175
|
+
Object.assign(defaultOption, option || {});
|
|
1176
|
+
const eventNameList = DOMUtilsCommonUtils.getTransitionEndNameList();
|
|
1177
|
+
DOMUtilsContext.on(element, eventNameList, null, handler, defaultOption);
|
|
1178
|
+
if (!defaultOption.once) {
|
|
1179
|
+
return {
|
|
1180
|
+
off() {
|
|
1181
|
+
DOMUtilsContext.off(element, eventNameList, null, handler, defaultOption);
|
|
1182
|
+
},
|
|
1183
|
+
};
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1116
1186
|
/**
|
|
1117
1187
|
* 当按键松开时触发事件
|
|
1118
1188
|
* keydown - > keypress - > keyup
|
|
@@ -1487,7 +1557,7 @@ define((function () { 'use strict';
|
|
|
1487
1557
|
super(option);
|
|
1488
1558
|
}
|
|
1489
1559
|
/** 版本号 */
|
|
1490
|
-
version = "2025.
|
|
1560
|
+
version = "2025.8.11";
|
|
1491
1561
|
attr(element, attrName, attrValue) {
|
|
1492
1562
|
let DOMUtilsContext = this;
|
|
1493
1563
|
if (typeof element === "string") {
|
|
@@ -1581,15 +1651,7 @@ define((function () { 'use strict';
|
|
|
1581
1651
|
* 把纯数字没有px的加上
|
|
1582
1652
|
*/
|
|
1583
1653
|
function handlePixe(propertyName, propertyValue) {
|
|
1584
|
-
let allowAddPixe = [
|
|
1585
|
-
"width",
|
|
1586
|
-
"height",
|
|
1587
|
-
"top",
|
|
1588
|
-
"left",
|
|
1589
|
-
"right",
|
|
1590
|
-
"bottom",
|
|
1591
|
-
"font-size",
|
|
1592
|
-
];
|
|
1654
|
+
let allowAddPixe = ["width", "height", "top", "left", "right", "bottom", "font-size"];
|
|
1593
1655
|
if (typeof propertyValue === "number") {
|
|
1594
1656
|
propertyValue = propertyValue.toString();
|
|
1595
1657
|
}
|
|
@@ -1631,8 +1693,7 @@ define((function () { 'use strict';
|
|
|
1631
1693
|
return;
|
|
1632
1694
|
}
|
|
1633
1695
|
let setStyleProperty = (propertyName, propertyValue) => {
|
|
1634
|
-
if (typeof propertyValue === "string" &&
|
|
1635
|
-
propertyValue.trim().endsWith("!important")) {
|
|
1696
|
+
if (typeof propertyValue === "string" && propertyValue.trim().endsWith("!important")) {
|
|
1636
1697
|
propertyValue = propertyValue
|
|
1637
1698
|
.trim()
|
|
1638
1699
|
.replace(/!important$/gi, "")
|
|
@@ -1646,9 +1707,7 @@ define((function () { 'use strict';
|
|
|
1646
1707
|
};
|
|
1647
1708
|
if (typeof property === "string") {
|
|
1648
1709
|
if (value == null) {
|
|
1649
|
-
return DOMUtilsContext.windowApi.globalThis
|
|
1650
|
-
.getComputedStyle(element)
|
|
1651
|
-
.getPropertyValue(property);
|
|
1710
|
+
return DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).getPropertyValue(property);
|
|
1652
1711
|
}
|
|
1653
1712
|
else {
|
|
1654
1713
|
setStyleProperty(property, value);
|
|
@@ -1751,12 +1810,8 @@ define((function () { 'use strict';
|
|
|
1751
1810
|
return transformInfo;
|
|
1752
1811
|
}
|
|
1753
1812
|
let elementTransform = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).transform;
|
|
1754
|
-
if (elementTransform != null &&
|
|
1755
|
-
|
|
1756
|
-
elementTransform !== "") {
|
|
1757
|
-
let elementTransformSplit = elementTransform
|
|
1758
|
-
.match(/\((.+)\)/)?.[1]
|
|
1759
|
-
.split(",");
|
|
1813
|
+
if (elementTransform != null && elementTransform !== "none" && elementTransform !== "") {
|
|
1814
|
+
let elementTransformSplit = elementTransform.match(/\((.+)\)/)?.[1].split(",");
|
|
1760
1815
|
if (elementTransformSplit) {
|
|
1761
1816
|
transform_left = Math.abs(parseInt(elementTransformSplit[4]));
|
|
1762
1817
|
transform_top = Math.abs(parseInt(elementTransformSplit[5]));
|
|
@@ -1794,8 +1849,7 @@ define((function () { 'use strict';
|
|
|
1794
1849
|
}
|
|
1795
1850
|
if (value == null) {
|
|
1796
1851
|
// 获取
|
|
1797
|
-
if (element.localName === "input" &&
|
|
1798
|
-
(element.type === "checkbox" || element.type === "radio")) {
|
|
1852
|
+
if (element.localName === "input" && (element.type === "checkbox" || element.type === "radio")) {
|
|
1799
1853
|
return element.checked;
|
|
1800
1854
|
}
|
|
1801
1855
|
else {
|
|
@@ -1804,8 +1858,7 @@ define((function () { 'use strict';
|
|
|
1804
1858
|
}
|
|
1805
1859
|
else {
|
|
1806
1860
|
// 设置
|
|
1807
|
-
if (element.localName === "input" &&
|
|
1808
|
-
(element.type === "checkbox" || element.type === "radio")) {
|
|
1861
|
+
if (element.localName === "input" && (element.type === "checkbox" || element.type === "radio")) {
|
|
1809
1862
|
element.checked = !!value;
|
|
1810
1863
|
}
|
|
1811
1864
|
else {
|
|
@@ -2059,7 +2112,15 @@ define((function () { 'use strict';
|
|
|
2059
2112
|
}
|
|
2060
2113
|
function elementAppendChild(ele, text) {
|
|
2061
2114
|
if (typeof content === "string") {
|
|
2062
|
-
ele
|
|
2115
|
+
if (ele instanceof DocumentFragment) {
|
|
2116
|
+
if (typeof text === "string") {
|
|
2117
|
+
text = DOMUtilsContext.parseHTML(text, true, false);
|
|
2118
|
+
}
|
|
2119
|
+
ele.appendChild(text);
|
|
2120
|
+
}
|
|
2121
|
+
else {
|
|
2122
|
+
ele.insertAdjacentHTML("beforeend", DOMUtilsCommonUtils.getSafeHTML(text));
|
|
2123
|
+
}
|
|
2063
2124
|
}
|
|
2064
2125
|
else {
|
|
2065
2126
|
ele.appendChild(text);
|
|
@@ -2070,6 +2131,7 @@ define((function () { 'use strict';
|
|
|
2070
2131
|
let fragment = DOMUtilsContext.windowApi.document.createDocumentFragment();
|
|
2071
2132
|
content.forEach((ele) => {
|
|
2072
2133
|
if (typeof ele === "string") {
|
|
2134
|
+
// 转为元素
|
|
2073
2135
|
ele = DOMUtilsContext.parseHTML(ele, true, false);
|
|
2074
2136
|
}
|
|
2075
2137
|
fragment.appendChild(ele);
|
|
@@ -2105,7 +2167,13 @@ define((function () { 'use strict';
|
|
|
2105
2167
|
return;
|
|
2106
2168
|
}
|
|
2107
2169
|
if (typeof content === "string") {
|
|
2108
|
-
element
|
|
2170
|
+
if (element instanceof DocumentFragment) {
|
|
2171
|
+
content = DOMUtilsContext.parseHTML(content, true, false);
|
|
2172
|
+
element.prepend(content);
|
|
2173
|
+
}
|
|
2174
|
+
else {
|
|
2175
|
+
element.insertAdjacentHTML("afterbegin", DOMUtilsCommonUtils.getSafeHTML(content));
|
|
2176
|
+
}
|
|
2109
2177
|
}
|
|
2110
2178
|
else {
|
|
2111
2179
|
let $firstChild = element.firstChild;
|
|
@@ -2278,16 +2346,14 @@ define((function () { 'use strict';
|
|
|
2278
2346
|
return;
|
|
2279
2347
|
}
|
|
2280
2348
|
if (DOMUtilsCommonUtils.isWin(element)) {
|
|
2281
|
-
return DOMUtilsContext.windowApi.window.document.documentElement
|
|
2282
|
-
.clientWidth;
|
|
2349
|
+
return DOMUtilsContext.windowApi.window.document.documentElement.clientWidth;
|
|
2283
2350
|
}
|
|
2284
2351
|
if (element.nodeType === 9) {
|
|
2285
2352
|
/* Document文档节点 */
|
|
2286
2353
|
element = element;
|
|
2287
2354
|
return Math.max(element.body.scrollWidth, element.documentElement.scrollWidth, element.body.offsetWidth, element.documentElement.offsetWidth, element.documentElement.clientWidth);
|
|
2288
2355
|
}
|
|
2289
|
-
if (isShow ||
|
|
2290
|
-
(!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2356
|
+
if (isShow || (!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2291
2357
|
/* 已显示 */
|
|
2292
2358
|
/* 不从style中获取对应的宽度,因为可能使用了class定义了width !important */
|
|
2293
2359
|
element = element;
|
|
@@ -2322,8 +2388,7 @@ define((function () { 'use strict';
|
|
|
2322
2388
|
height(element, isShow = false) {
|
|
2323
2389
|
let DOMUtilsContext = this;
|
|
2324
2390
|
if (DOMUtilsCommonUtils.isWin(element)) {
|
|
2325
|
-
return DOMUtilsContext.windowApi.window.document.documentElement
|
|
2326
|
-
.clientHeight;
|
|
2391
|
+
return DOMUtilsContext.windowApi.window.document.documentElement.clientHeight;
|
|
2327
2392
|
}
|
|
2328
2393
|
if (typeof element === "string") {
|
|
2329
2394
|
element = DOMUtilsContext.selector(element);
|
|
@@ -2337,8 +2402,7 @@ define((function () { 'use strict';
|
|
|
2337
2402
|
/* Document文档节点 */
|
|
2338
2403
|
return Math.max(element.body.scrollHeight, element.documentElement.scrollHeight, element.body.offsetHeight, element.documentElement.offsetHeight, element.documentElement.clientHeight);
|
|
2339
2404
|
}
|
|
2340
|
-
if (isShow ||
|
|
2341
|
-
(!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2405
|
+
if (isShow || (!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2342
2406
|
element = element;
|
|
2343
2407
|
/* 已显示 */
|
|
2344
2408
|
/* 从style中获取对应的高度,因为可能使用了class定义了width !important */
|
|
@@ -2466,8 +2530,7 @@ define((function () { 'use strict';
|
|
|
2466
2530
|
let to = {};
|
|
2467
2531
|
for (let prop in styles) {
|
|
2468
2532
|
from[prop] =
|
|
2469
|
-
element.style[prop] ||
|
|
2470
|
-
DOMUtilsContext.windowApi.globalThis.getComputedStyle(element)[prop];
|
|
2533
|
+
element.style[prop] || DOMUtilsContext.windowApi.globalThis.getComputedStyle(element)[prop];
|
|
2471
2534
|
to[prop] = styles[prop];
|
|
2472
2535
|
}
|
|
2473
2536
|
let timer = DOMUtilsCommonUtils.setInterval(function () {
|
|
@@ -2477,8 +2540,7 @@ define((function () { 'use strict';
|
|
|
2477
2540
|
progress = 1;
|
|
2478
2541
|
}
|
|
2479
2542
|
for (let prop in styles) {
|
|
2480
|
-
element.style[prop] =
|
|
2481
|
-
from[prop] + (to[prop] - from[prop]) * progress + "px";
|
|
2543
|
+
element.style[prop] = from[prop] + (to[prop] - from[prop]) * progress + "px";
|
|
2482
2544
|
}
|
|
2483
2545
|
if (progress === 1) {
|
|
2484
2546
|
DOMUtilsCommonUtils.clearInterval(timer);
|
|
@@ -2563,8 +2625,7 @@ define((function () { 'use strict';
|
|
|
2563
2625
|
if (element == null) {
|
|
2564
2626
|
return;
|
|
2565
2627
|
}
|
|
2566
|
-
return Array.from(element.parentElement
|
|
2567
|
-
.children).filter((child) => child !== element);
|
|
2628
|
+
return Array.from(element.parentElement.children).filter((child) => child !== element);
|
|
2568
2629
|
}
|
|
2569
2630
|
/**
|
|
2570
2631
|
* 获取当前元素的父元素
|
|
@@ -2640,14 +2701,7 @@ define((function () { 'use strict';
|
|
|
2640
2701
|
if (element.name &&
|
|
2641
2702
|
!element.disabled &&
|
|
2642
2703
|
(element.checked ||
|
|
2643
|
-
[
|
|
2644
|
-
"text",
|
|
2645
|
-
"hidden",
|
|
2646
|
-
"password",
|
|
2647
|
-
"textarea",
|
|
2648
|
-
"select-one",
|
|
2649
|
-
"select-multiple",
|
|
2650
|
-
].includes(element.type))) {
|
|
2704
|
+
["text", "hidden", "password", "textarea", "select-one", "select-multiple"].includes(element.type))) {
|
|
2651
2705
|
if (element.type === "select-multiple") {
|
|
2652
2706
|
for (let j = 0; j < element.options.length; j++) {
|
|
2653
2707
|
if (element.options[j].selected) {
|
|
@@ -2867,9 +2921,7 @@ define((function () { 'use strict';
|
|
|
2867
2921
|
});
|
|
2868
2922
|
return;
|
|
2869
2923
|
}
|
|
2870
|
-
if (DOMUtilsContext.windowApi.globalThis
|
|
2871
|
-
.getComputedStyle(element)
|
|
2872
|
-
.getPropertyValue("display") === "none") {
|
|
2924
|
+
if (DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).getPropertyValue("display") === "none") {
|
|
2873
2925
|
DOMUtilsContext.show(element, checkVisiblie);
|
|
2874
2926
|
}
|
|
2875
2927
|
else {
|
|
@@ -2914,9 +2966,7 @@ define((function () { 'use strict';
|
|
|
2914
2966
|
selectionStart = Math.min($input.value.length, selectionStart);
|
|
2915
2967
|
if (typeof selectionEnd == "string")
|
|
2916
2968
|
selectionEnd = parseFloat(selectionEnd);
|
|
2917
|
-
if (typeof selectionEnd != "number" ||
|
|
2918
|
-
isNaN(selectionEnd) ||
|
|
2919
|
-
selectionEnd < selectionStart) {
|
|
2969
|
+
if (typeof selectionEnd != "number" || isNaN(selectionEnd) || selectionEnd < selectionStart) {
|
|
2920
2970
|
selectionEnd = selectionStart;
|
|
2921
2971
|
}
|
|
2922
2972
|
if (selectionEnd < 0)
|
|
@@ -3003,11 +3053,7 @@ define((function () { 'use strict';
|
|
|
3003
3053
|
var isBoxModel = $box.offsetWidth == 2;
|
|
3004
3054
|
body.removeChild($box);
|
|
3005
3055
|
let $boxRect = $input.getBoundingClientRect();
|
|
3006
|
-
var clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, scrollTop = win.pageYOffset ||
|
|
3007
|
-
(isBoxModel && docElem.scrollTop) ||
|
|
3008
|
-
body.scrollTop, scrollLeft = win.pageXOffset ||
|
|
3009
|
-
(isBoxModel && docElem.scrollLeft) ||
|
|
3010
|
-
body.scrollLeft;
|
|
3056
|
+
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;
|
|
3011
3057
|
return {
|
|
3012
3058
|
top: $boxRect.top + scrollTop - clientTop,
|
|
3013
3059
|
left: $boxRect.left + scrollLeft - clientLeft,
|
|
@@ -3026,6 +3072,14 @@ define((function () { 'use strict';
|
|
|
3026
3072
|
return isNumber ? parseFloat(val) : val;
|
|
3027
3073
|
}
|
|
3028
3074
|
}
|
|
3075
|
+
/** 获取 animationend 在各个浏览器的兼容名 */
|
|
3076
|
+
getAnimationEndNameList() {
|
|
3077
|
+
return DOMUtilsCommonUtils.getAnimationEndNameList();
|
|
3078
|
+
}
|
|
3079
|
+
/** 获取 transitionend 在各个浏览器的兼容名 */
|
|
3080
|
+
getTransitionEndNameList() {
|
|
3081
|
+
return DOMUtilsCommonUtils.getTransitionEndNameList();
|
|
3082
|
+
}
|
|
3029
3083
|
}
|
|
3030
3084
|
let domUtils = new DOMUtils();
|
|
3031
3085
|
|