@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.system.js
CHANGED
|
@@ -283,7 +283,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
283
283
|
};
|
|
284
284
|
|
|
285
285
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
286
|
-
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),
|
|
286
|
+
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
|
|
287
287
|
|
|
288
288
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
289
289
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -483,6 +483,14 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
483
483
|
isNodeList($ele) {
|
|
484
484
|
return Array.isArray($ele) || $ele instanceof NodeList;
|
|
485
485
|
},
|
|
486
|
+
/** 获取 animationend 在各个浏览器的兼容名 */
|
|
487
|
+
getAnimationEndNameList() {
|
|
488
|
+
return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
|
|
489
|
+
},
|
|
490
|
+
/** 获取 transitionend 在各个浏览器的兼容名 */
|
|
491
|
+
getTransitionEndNameList() {
|
|
492
|
+
return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
|
|
493
|
+
},
|
|
486
494
|
};
|
|
487
495
|
|
|
488
496
|
/* 数据 */
|
|
@@ -605,8 +613,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
605
613
|
: event.target;
|
|
606
614
|
let totalParent = elementItem;
|
|
607
615
|
if (DOMUtilsCommonUtils.isWin(totalParent)) {
|
|
608
|
-
if (totalParent ===
|
|
609
|
-
DOMUtilsContext.windowApi.document) {
|
|
616
|
+
if (totalParent === DOMUtilsContext.windowApi.document) {
|
|
610
617
|
totalParent = DOMUtilsContext.windowApi.document.documentElement;
|
|
611
618
|
}
|
|
612
619
|
}
|
|
@@ -674,8 +681,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
674
681
|
if (typeof currentParam === "boolean") {
|
|
675
682
|
option.capture = currentParam;
|
|
676
683
|
}
|
|
677
|
-
else if (typeof currentParam === "object" &&
|
|
678
|
-
"capture" in currentParam) {
|
|
684
|
+
else if (typeof currentParam === "object" && "capture" in currentParam) {
|
|
679
685
|
option.capture = currentParam.capture;
|
|
680
686
|
}
|
|
681
687
|
return option;
|
|
@@ -737,8 +743,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
737
743
|
// 目标函数、事件名
|
|
738
744
|
isRemoveAll = true;
|
|
739
745
|
}
|
|
740
|
-
else if ((args.length === 3 && typeof args[2] === "string") ||
|
|
741
|
-
Array.isArray(args[2])) {
|
|
746
|
+
else if ((args.length === 3 && typeof args[2] === "string") || Array.isArray(args[2])) {
|
|
742
747
|
// 目标函数、事件名、子元素选择器
|
|
743
748
|
isRemoveAll = true;
|
|
744
749
|
}
|
|
@@ -753,9 +758,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
753
758
|
for (let index = 0; index < handlers.length; index++) {
|
|
754
759
|
let handler = handlers[index];
|
|
755
760
|
let flag = true;
|
|
756
|
-
if (flag &&
|
|
757
|
-
listenerCallBack &&
|
|
758
|
-
handler.originCallBack !== listenerCallBack) {
|
|
761
|
+
if (flag && listenerCallBack && handler.originCallBack !== listenerCallBack) {
|
|
759
762
|
// callback不同
|
|
760
763
|
flag = false;
|
|
761
764
|
}
|
|
@@ -815,9 +818,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
815
818
|
return;
|
|
816
819
|
}
|
|
817
820
|
let elementEvents = elementItem[symbolEvents] || {};
|
|
818
|
-
let iterEventNameList = eventTypeList.length
|
|
819
|
-
? eventTypeList
|
|
820
|
-
: Object.keys(elementEvents);
|
|
821
|
+
let iterEventNameList = eventTypeList.length ? eventTypeList : Object.keys(elementEvents);
|
|
821
822
|
iterEventNameList.forEach((eventName) => {
|
|
822
823
|
let handlers = elementEvents[eventName];
|
|
823
824
|
if (!handlers) {
|
|
@@ -854,8 +855,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
854
855
|
try {
|
|
855
856
|
if (DOMUtilsContext.windowApi.document.readyState === "complete" ||
|
|
856
857
|
(DOMUtilsContext.windowApi.document.readyState !== "loading" &&
|
|
857
|
-
!DOMUtilsContext.windowApi.document.documentElement
|
|
858
|
-
.doScroll)) {
|
|
858
|
+
!DOMUtilsContext.windowApi.document.documentElement.doScroll)) {
|
|
859
859
|
return true;
|
|
860
860
|
}
|
|
861
861
|
else {
|
|
@@ -1116,6 +1116,76 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1116
1116
|
DOMUtilsContext.on(element, "mouseenter", null, handler, option);
|
|
1117
1117
|
DOMUtilsContext.on(element, "mouseleave", null, handler, option);
|
|
1118
1118
|
}
|
|
1119
|
+
/**
|
|
1120
|
+
* 当动画结束时触发事件
|
|
1121
|
+
* @param element 监听的元素
|
|
1122
|
+
* @param handler 触发的回调函数
|
|
1123
|
+
* @param option 配置项,这里默认配置once为true
|
|
1124
|
+
*/
|
|
1125
|
+
animationend(element, handler, option) {
|
|
1126
|
+
let DOMUtilsContext = this;
|
|
1127
|
+
if (typeof element === "string") {
|
|
1128
|
+
element = DOMUtilsContext.selector(element);
|
|
1129
|
+
}
|
|
1130
|
+
if (element == null) {
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
if (DOMUtilsCommonUtils.isNodeList(element)) {
|
|
1134
|
+
// 设置
|
|
1135
|
+
element.forEach(($ele) => {
|
|
1136
|
+
DOMUtilsContext.animationend($ele, handler, option);
|
|
1137
|
+
});
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
const defaultOption = {
|
|
1141
|
+
once: true,
|
|
1142
|
+
};
|
|
1143
|
+
Object.assign(defaultOption, option || {});
|
|
1144
|
+
const eventNameList = DOMUtilsCommonUtils.getAnimationEndNameList();
|
|
1145
|
+
DOMUtilsContext.on(element, eventNameList, null, handler, defaultOption);
|
|
1146
|
+
if (!defaultOption.once) {
|
|
1147
|
+
return {
|
|
1148
|
+
off() {
|
|
1149
|
+
DOMUtilsContext.off(element, eventNameList, null, handler, defaultOption);
|
|
1150
|
+
},
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
/**
|
|
1155
|
+
* 当过渡结束时触发事件
|
|
1156
|
+
* @param element 监听的元素
|
|
1157
|
+
* @param handler 触发的回调函数
|
|
1158
|
+
* @param option 配置项,这里默认配置once为true
|
|
1159
|
+
*/
|
|
1160
|
+
transitionend(element, handler, option) {
|
|
1161
|
+
let DOMUtilsContext = this;
|
|
1162
|
+
if (typeof element === "string") {
|
|
1163
|
+
element = DOMUtilsContext.selector(element);
|
|
1164
|
+
}
|
|
1165
|
+
if (element == null) {
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
if (DOMUtilsCommonUtils.isNodeList(element)) {
|
|
1169
|
+
// 设置
|
|
1170
|
+
element.forEach(($ele) => {
|
|
1171
|
+
DOMUtilsContext.transitionend($ele, handler, option);
|
|
1172
|
+
});
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
const defaultOption = {
|
|
1176
|
+
once: true,
|
|
1177
|
+
};
|
|
1178
|
+
Object.assign(defaultOption, option || {});
|
|
1179
|
+
const eventNameList = DOMUtilsCommonUtils.getTransitionEndNameList();
|
|
1180
|
+
DOMUtilsContext.on(element, eventNameList, null, handler, defaultOption);
|
|
1181
|
+
if (!defaultOption.once) {
|
|
1182
|
+
return {
|
|
1183
|
+
off() {
|
|
1184
|
+
DOMUtilsContext.off(element, eventNameList, null, handler, defaultOption);
|
|
1185
|
+
},
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1119
1189
|
/**
|
|
1120
1190
|
* 当按键松开时触发事件
|
|
1121
1191
|
* keydown - > keypress - > keyup
|
|
@@ -1490,7 +1560,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1490
1560
|
super(option);
|
|
1491
1561
|
}
|
|
1492
1562
|
/** 版本号 */
|
|
1493
|
-
version = "2025.
|
|
1563
|
+
version = "2025.8.11";
|
|
1494
1564
|
attr(element, attrName, attrValue) {
|
|
1495
1565
|
let DOMUtilsContext = this;
|
|
1496
1566
|
if (typeof element === "string") {
|
|
@@ -1584,15 +1654,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1584
1654
|
* 把纯数字没有px的加上
|
|
1585
1655
|
*/
|
|
1586
1656
|
function handlePixe(propertyName, propertyValue) {
|
|
1587
|
-
let allowAddPixe = [
|
|
1588
|
-
"width",
|
|
1589
|
-
"height",
|
|
1590
|
-
"top",
|
|
1591
|
-
"left",
|
|
1592
|
-
"right",
|
|
1593
|
-
"bottom",
|
|
1594
|
-
"font-size",
|
|
1595
|
-
];
|
|
1657
|
+
let allowAddPixe = ["width", "height", "top", "left", "right", "bottom", "font-size"];
|
|
1596
1658
|
if (typeof propertyValue === "number") {
|
|
1597
1659
|
propertyValue = propertyValue.toString();
|
|
1598
1660
|
}
|
|
@@ -1634,8 +1696,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1634
1696
|
return;
|
|
1635
1697
|
}
|
|
1636
1698
|
let setStyleProperty = (propertyName, propertyValue) => {
|
|
1637
|
-
if (typeof propertyValue === "string" &&
|
|
1638
|
-
propertyValue.trim().endsWith("!important")) {
|
|
1699
|
+
if (typeof propertyValue === "string" && propertyValue.trim().endsWith("!important")) {
|
|
1639
1700
|
propertyValue = propertyValue
|
|
1640
1701
|
.trim()
|
|
1641
1702
|
.replace(/!important$/gi, "")
|
|
@@ -1649,9 +1710,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1649
1710
|
};
|
|
1650
1711
|
if (typeof property === "string") {
|
|
1651
1712
|
if (value == null) {
|
|
1652
|
-
return DOMUtilsContext.windowApi.globalThis
|
|
1653
|
-
.getComputedStyle(element)
|
|
1654
|
-
.getPropertyValue(property);
|
|
1713
|
+
return DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).getPropertyValue(property);
|
|
1655
1714
|
}
|
|
1656
1715
|
else {
|
|
1657
1716
|
setStyleProperty(property, value);
|
|
@@ -1754,12 +1813,8 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1754
1813
|
return transformInfo;
|
|
1755
1814
|
}
|
|
1756
1815
|
let elementTransform = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).transform;
|
|
1757
|
-
if (elementTransform != null &&
|
|
1758
|
-
|
|
1759
|
-
elementTransform !== "") {
|
|
1760
|
-
let elementTransformSplit = elementTransform
|
|
1761
|
-
.match(/\((.+)\)/)?.[1]
|
|
1762
|
-
.split(",");
|
|
1816
|
+
if (elementTransform != null && elementTransform !== "none" && elementTransform !== "") {
|
|
1817
|
+
let elementTransformSplit = elementTransform.match(/\((.+)\)/)?.[1].split(",");
|
|
1763
1818
|
if (elementTransformSplit) {
|
|
1764
1819
|
transform_left = Math.abs(parseInt(elementTransformSplit[4]));
|
|
1765
1820
|
transform_top = Math.abs(parseInt(elementTransformSplit[5]));
|
|
@@ -1797,8 +1852,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1797
1852
|
}
|
|
1798
1853
|
if (value == null) {
|
|
1799
1854
|
// 获取
|
|
1800
|
-
if (element.localName === "input" &&
|
|
1801
|
-
(element.type === "checkbox" || element.type === "radio")) {
|
|
1855
|
+
if (element.localName === "input" && (element.type === "checkbox" || element.type === "radio")) {
|
|
1802
1856
|
return element.checked;
|
|
1803
1857
|
}
|
|
1804
1858
|
else {
|
|
@@ -1807,8 +1861,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1807
1861
|
}
|
|
1808
1862
|
else {
|
|
1809
1863
|
// 设置
|
|
1810
|
-
if (element.localName === "input" &&
|
|
1811
|
-
(element.type === "checkbox" || element.type === "radio")) {
|
|
1864
|
+
if (element.localName === "input" && (element.type === "checkbox" || element.type === "radio")) {
|
|
1812
1865
|
element.checked = !!value;
|
|
1813
1866
|
}
|
|
1814
1867
|
else {
|
|
@@ -2062,7 +2115,15 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2062
2115
|
}
|
|
2063
2116
|
function elementAppendChild(ele, text) {
|
|
2064
2117
|
if (typeof content === "string") {
|
|
2065
|
-
ele
|
|
2118
|
+
if (ele instanceof DocumentFragment) {
|
|
2119
|
+
if (typeof text === "string") {
|
|
2120
|
+
text = DOMUtilsContext.parseHTML(text, true, false);
|
|
2121
|
+
}
|
|
2122
|
+
ele.appendChild(text);
|
|
2123
|
+
}
|
|
2124
|
+
else {
|
|
2125
|
+
ele.insertAdjacentHTML("beforeend", DOMUtilsCommonUtils.getSafeHTML(text));
|
|
2126
|
+
}
|
|
2066
2127
|
}
|
|
2067
2128
|
else {
|
|
2068
2129
|
ele.appendChild(text);
|
|
@@ -2073,6 +2134,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2073
2134
|
let fragment = DOMUtilsContext.windowApi.document.createDocumentFragment();
|
|
2074
2135
|
content.forEach((ele) => {
|
|
2075
2136
|
if (typeof ele === "string") {
|
|
2137
|
+
// 转为元素
|
|
2076
2138
|
ele = DOMUtilsContext.parseHTML(ele, true, false);
|
|
2077
2139
|
}
|
|
2078
2140
|
fragment.appendChild(ele);
|
|
@@ -2108,7 +2170,13 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2108
2170
|
return;
|
|
2109
2171
|
}
|
|
2110
2172
|
if (typeof content === "string") {
|
|
2111
|
-
element
|
|
2173
|
+
if (element instanceof DocumentFragment) {
|
|
2174
|
+
content = DOMUtilsContext.parseHTML(content, true, false);
|
|
2175
|
+
element.prepend(content);
|
|
2176
|
+
}
|
|
2177
|
+
else {
|
|
2178
|
+
element.insertAdjacentHTML("afterbegin", DOMUtilsCommonUtils.getSafeHTML(content));
|
|
2179
|
+
}
|
|
2112
2180
|
}
|
|
2113
2181
|
else {
|
|
2114
2182
|
let $firstChild = element.firstChild;
|
|
@@ -2281,16 +2349,14 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2281
2349
|
return;
|
|
2282
2350
|
}
|
|
2283
2351
|
if (DOMUtilsCommonUtils.isWin(element)) {
|
|
2284
|
-
return DOMUtilsContext.windowApi.window.document.documentElement
|
|
2285
|
-
.clientWidth;
|
|
2352
|
+
return DOMUtilsContext.windowApi.window.document.documentElement.clientWidth;
|
|
2286
2353
|
}
|
|
2287
2354
|
if (element.nodeType === 9) {
|
|
2288
2355
|
/* Document文档节点 */
|
|
2289
2356
|
element = element;
|
|
2290
2357
|
return Math.max(element.body.scrollWidth, element.documentElement.scrollWidth, element.body.offsetWidth, element.documentElement.offsetWidth, element.documentElement.clientWidth);
|
|
2291
2358
|
}
|
|
2292
|
-
if (isShow ||
|
|
2293
|
-
(!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2359
|
+
if (isShow || (!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2294
2360
|
/* 已显示 */
|
|
2295
2361
|
/* 不从style中获取对应的宽度,因为可能使用了class定义了width !important */
|
|
2296
2362
|
element = element;
|
|
@@ -2325,8 +2391,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2325
2391
|
height(element, isShow = false) {
|
|
2326
2392
|
let DOMUtilsContext = this;
|
|
2327
2393
|
if (DOMUtilsCommonUtils.isWin(element)) {
|
|
2328
|
-
return DOMUtilsContext.windowApi.window.document.documentElement
|
|
2329
|
-
.clientHeight;
|
|
2394
|
+
return DOMUtilsContext.windowApi.window.document.documentElement.clientHeight;
|
|
2330
2395
|
}
|
|
2331
2396
|
if (typeof element === "string") {
|
|
2332
2397
|
element = DOMUtilsContext.selector(element);
|
|
@@ -2340,8 +2405,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2340
2405
|
/* Document文档节点 */
|
|
2341
2406
|
return Math.max(element.body.scrollHeight, element.documentElement.scrollHeight, element.body.offsetHeight, element.documentElement.offsetHeight, element.documentElement.clientHeight);
|
|
2342
2407
|
}
|
|
2343
|
-
if (isShow ||
|
|
2344
|
-
(!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2408
|
+
if (isShow || (!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2345
2409
|
element = element;
|
|
2346
2410
|
/* 已显示 */
|
|
2347
2411
|
/* 从style中获取对应的高度,因为可能使用了class定义了width !important */
|
|
@@ -2469,8 +2533,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2469
2533
|
let to = {};
|
|
2470
2534
|
for (let prop in styles) {
|
|
2471
2535
|
from[prop] =
|
|
2472
|
-
element.style[prop] ||
|
|
2473
|
-
DOMUtilsContext.windowApi.globalThis.getComputedStyle(element)[prop];
|
|
2536
|
+
element.style[prop] || DOMUtilsContext.windowApi.globalThis.getComputedStyle(element)[prop];
|
|
2474
2537
|
to[prop] = styles[prop];
|
|
2475
2538
|
}
|
|
2476
2539
|
let timer = DOMUtilsCommonUtils.setInterval(function () {
|
|
@@ -2480,8 +2543,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2480
2543
|
progress = 1;
|
|
2481
2544
|
}
|
|
2482
2545
|
for (let prop in styles) {
|
|
2483
|
-
element.style[prop] =
|
|
2484
|
-
from[prop] + (to[prop] - from[prop]) * progress + "px";
|
|
2546
|
+
element.style[prop] = from[prop] + (to[prop] - from[prop]) * progress + "px";
|
|
2485
2547
|
}
|
|
2486
2548
|
if (progress === 1) {
|
|
2487
2549
|
DOMUtilsCommonUtils.clearInterval(timer);
|
|
@@ -2566,8 +2628,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2566
2628
|
if (element == null) {
|
|
2567
2629
|
return;
|
|
2568
2630
|
}
|
|
2569
|
-
return Array.from(element.parentElement
|
|
2570
|
-
.children).filter((child) => child !== element);
|
|
2631
|
+
return Array.from(element.parentElement.children).filter((child) => child !== element);
|
|
2571
2632
|
}
|
|
2572
2633
|
/**
|
|
2573
2634
|
* 获取当前元素的父元素
|
|
@@ -2643,14 +2704,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2643
2704
|
if (element.name &&
|
|
2644
2705
|
!element.disabled &&
|
|
2645
2706
|
(element.checked ||
|
|
2646
|
-
[
|
|
2647
|
-
"text",
|
|
2648
|
-
"hidden",
|
|
2649
|
-
"password",
|
|
2650
|
-
"textarea",
|
|
2651
|
-
"select-one",
|
|
2652
|
-
"select-multiple",
|
|
2653
|
-
].includes(element.type))) {
|
|
2707
|
+
["text", "hidden", "password", "textarea", "select-one", "select-multiple"].includes(element.type))) {
|
|
2654
2708
|
if (element.type === "select-multiple") {
|
|
2655
2709
|
for (let j = 0; j < element.options.length; j++) {
|
|
2656
2710
|
if (element.options[j].selected) {
|
|
@@ -2870,9 +2924,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2870
2924
|
});
|
|
2871
2925
|
return;
|
|
2872
2926
|
}
|
|
2873
|
-
if (DOMUtilsContext.windowApi.globalThis
|
|
2874
|
-
.getComputedStyle(element)
|
|
2875
|
-
.getPropertyValue("display") === "none") {
|
|
2927
|
+
if (DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).getPropertyValue("display") === "none") {
|
|
2876
2928
|
DOMUtilsContext.show(element, checkVisiblie);
|
|
2877
2929
|
}
|
|
2878
2930
|
else {
|
|
@@ -2917,9 +2969,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2917
2969
|
selectionStart = Math.min($input.value.length, selectionStart);
|
|
2918
2970
|
if (typeof selectionEnd == "string")
|
|
2919
2971
|
selectionEnd = parseFloat(selectionEnd);
|
|
2920
|
-
if (typeof selectionEnd != "number" ||
|
|
2921
|
-
isNaN(selectionEnd) ||
|
|
2922
|
-
selectionEnd < selectionStart) {
|
|
2972
|
+
if (typeof selectionEnd != "number" || isNaN(selectionEnd) || selectionEnd < selectionStart) {
|
|
2923
2973
|
selectionEnd = selectionStart;
|
|
2924
2974
|
}
|
|
2925
2975
|
if (selectionEnd < 0)
|
|
@@ -3006,11 +3056,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
3006
3056
|
var isBoxModel = $box.offsetWidth == 2;
|
|
3007
3057
|
body.removeChild($box);
|
|
3008
3058
|
let $boxRect = $input.getBoundingClientRect();
|
|
3009
|
-
var clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, scrollTop = win.pageYOffset ||
|
|
3010
|
-
(isBoxModel && docElem.scrollTop) ||
|
|
3011
|
-
body.scrollTop, scrollLeft = win.pageXOffset ||
|
|
3012
|
-
(isBoxModel && docElem.scrollLeft) ||
|
|
3013
|
-
body.scrollLeft;
|
|
3059
|
+
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;
|
|
3014
3060
|
return {
|
|
3015
3061
|
top: $boxRect.top + scrollTop - clientTop,
|
|
3016
3062
|
left: $boxRect.left + scrollLeft - clientLeft,
|
|
@@ -3029,6 +3075,14 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
3029
3075
|
return isNumber ? parseFloat(val) : val;
|
|
3030
3076
|
}
|
|
3031
3077
|
}
|
|
3078
|
+
/** 获取 animationend 在各个浏览器的兼容名 */
|
|
3079
|
+
getAnimationEndNameList() {
|
|
3080
|
+
return DOMUtilsCommonUtils.getAnimationEndNameList();
|
|
3081
|
+
}
|
|
3082
|
+
/** 获取 transitionend 在各个浏览器的兼容名 */
|
|
3083
|
+
getTransitionEndNameList() {
|
|
3084
|
+
return DOMUtilsCommonUtils.getTransitionEndNameList();
|
|
3085
|
+
}
|
|
3032
3086
|
}
|
|
3033
3087
|
let domUtils = exports("default", new DOMUtils());
|
|
3034
3088
|
|