@whitesev/domutils 1.5.10 → 1.6.0
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 +186 -205
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +186 -205
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +186 -205
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +186 -205
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +186 -205
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +186 -205
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/DOMUtils.d.ts +6 -6
- package/dist/types/src/types/DOMUtilsEvent.d.ts +2 -1
- package/package.json +11 -8
- package/src/DOMUtils.ts +86 -257
- package/src/DOMUtilsCommonUtils.ts +1 -4
- package/src/DOMUtilsData.ts +1 -3
- package/src/DOMUtilsEvent.ts +40 -174
- package/src/types/DOMUtilsEvent.d.ts +2 -1
package/dist/index.amd.js
CHANGED
|
@@ -100,155 +100,168 @@ define((function () { 'use strict';
|
|
|
100
100
|
const cache = createCache(LAST_NUMBER_WEAK_MAP);
|
|
101
101
|
const generateUniqueNumber = createGenerateUniqueNumber(cache, LAST_NUMBER_WEAK_MAP);
|
|
102
102
|
|
|
103
|
-
const
|
|
104
|
-
return
|
|
103
|
+
const isMessagePort = (sender) => {
|
|
104
|
+
return typeof sender.start === 'function';
|
|
105
105
|
};
|
|
106
106
|
|
|
107
|
-
const
|
|
108
|
-
return typeof message.id === 'number' && typeof message.result === 'boolean';
|
|
109
|
-
};
|
|
107
|
+
const PORT_MAP = new WeakMap();
|
|
110
108
|
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const timerIdAndTimerType = unrespondedRequests.get(idOrFunc);
|
|
127
|
-
if (timerIdAndTimerType === undefined ||
|
|
128
|
-
timerIdAndTimerType.timerId !== timerId ||
|
|
129
|
-
timerIdAndTimerType.timerType !== timerType) {
|
|
130
|
-
throw new Error('The timer is in an undefined state.');
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
else if (typeof idOrFunc === 'function') {
|
|
134
|
-
idOrFunc();
|
|
135
|
-
}
|
|
109
|
+
const extendBrokerImplementation = (partialBrokerImplementation) => ({
|
|
110
|
+
...partialBrokerImplementation,
|
|
111
|
+
connect: ({ call }) => {
|
|
112
|
+
return async () => {
|
|
113
|
+
const { port1, port2 } = new MessageChannel();
|
|
114
|
+
const portId = await call('connect', { port: port1 }, [port1]);
|
|
115
|
+
PORT_MAP.set(port2, portId);
|
|
116
|
+
return port2;
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
disconnect: ({ call }) => {
|
|
120
|
+
return async (port) => {
|
|
121
|
+
const portId = PORT_MAP.get(port);
|
|
122
|
+
if (portId === undefined) {
|
|
123
|
+
throw new Error('The given port is not connected.');
|
|
136
124
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
125
|
+
await call('disconnect', { portId });
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
isSupported: ({ call }) => {
|
|
129
|
+
return () => call('isSupported');
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const ONGOING_REQUESTS = new WeakMap();
|
|
134
|
+
const createOrGetOngoingRequests = (sender) => {
|
|
135
|
+
if (ONGOING_REQUESTS.has(sender)) {
|
|
136
|
+
// @todo TypeScript needs to be convinced that has() works as expected.
|
|
137
|
+
return ONGOING_REQUESTS.get(sender);
|
|
138
|
+
}
|
|
139
|
+
const ongoingRequests = new Map();
|
|
140
|
+
ONGOING_REQUESTS.set(sender, ongoingRequests);
|
|
141
|
+
return ongoingRequests;
|
|
142
|
+
};
|
|
143
|
+
const createBroker = (brokerImplementation) => {
|
|
144
|
+
const fullBrokerImplementation = extendBrokerImplementation(brokerImplementation);
|
|
145
|
+
return (sender) => {
|
|
146
|
+
const ongoingRequests = createOrGetOngoingRequests(sender);
|
|
147
|
+
sender.addEventListener('message', (({ data: message }) => {
|
|
148
|
+
const { id } = message;
|
|
149
|
+
if (id !== null && ongoingRequests.has(id)) {
|
|
150
|
+
const { reject, resolve } = ongoingRequests.get(id);
|
|
151
|
+
ongoingRequests.delete(id);
|
|
152
|
+
if (message.error === undefined) {
|
|
153
|
+
resolve(message.result);
|
|
149
154
|
}
|
|
150
|
-
else
|
|
151
|
-
|
|
152
|
-
// A timeout can be savely deleted because it is only called once.
|
|
153
|
-
scheduledTimeoutFunctions.delete(timerId);
|
|
155
|
+
else {
|
|
156
|
+
reject(new Error(message.error.message));
|
|
154
157
|
}
|
|
155
158
|
}
|
|
159
|
+
}));
|
|
160
|
+
if (isMessagePort(sender)) {
|
|
161
|
+
sender.start();
|
|
156
162
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
scheduledTimeoutFunctions.delete(timerId);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
const { error: { message } } = data;
|
|
174
|
-
throw new Error(message);
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
const clearInterval = (timerId) => {
|
|
178
|
-
if (typeof scheduledIntervalFunctions.get(timerId) === 'function') {
|
|
179
|
-
const id = generateUniqueNumber(unrespondedRequests);
|
|
180
|
-
unrespondedRequests.set(id, { timerId, timerType: 'interval' });
|
|
181
|
-
scheduledIntervalFunctions.set(timerId, id);
|
|
182
|
-
worker.postMessage({
|
|
183
|
-
id,
|
|
184
|
-
method: 'clear',
|
|
185
|
-
params: { timerId, timerType: 'interval' }
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
const clearTimeout = (timerId) => {
|
|
190
|
-
if (typeof scheduledTimeoutFunctions.get(timerId) === 'function') {
|
|
191
|
-
const id = generateUniqueNumber(unrespondedRequests);
|
|
192
|
-
unrespondedRequests.set(id, { timerId, timerType: 'timeout' });
|
|
193
|
-
scheduledTimeoutFunctions.set(timerId, id);
|
|
194
|
-
worker.postMessage({
|
|
195
|
-
id,
|
|
196
|
-
method: 'clear',
|
|
197
|
-
params: { timerId, timerType: 'timeout' }
|
|
163
|
+
const call = (method, params = null, transferables = []) => {
|
|
164
|
+
return new Promise((resolve, reject) => {
|
|
165
|
+
const id = generateUniqueNumber(ongoingRequests);
|
|
166
|
+
ongoingRequests.set(id, { reject, resolve });
|
|
167
|
+
if (params === null) {
|
|
168
|
+
sender.postMessage({ id, method }, transferables);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
sender.postMessage({ id, method, params }, transferables);
|
|
172
|
+
}
|
|
198
173
|
});
|
|
174
|
+
};
|
|
175
|
+
const notify = (method, params, transferables = []) => {
|
|
176
|
+
sender.postMessage({ id: null, method, params }, transferables);
|
|
177
|
+
};
|
|
178
|
+
let functions = {};
|
|
179
|
+
for (const [key, handler] of Object.entries(fullBrokerImplementation)) {
|
|
180
|
+
functions = { ...functions, [key]: handler({ call, notify }) };
|
|
199
181
|
}
|
|
182
|
+
return { ...functions };
|
|
200
183
|
};
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
timerId,
|
|
214
|
-
timerType: 'interval'
|
|
215
|
-
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// Prefilling the Maps with a function indexed by zero is necessary to be compliant with the specification.
|
|
187
|
+
const scheduledIntervalsState = new Map([[0, null]]); // tslint:disable-line no-empty
|
|
188
|
+
const scheduledTimeoutsState = new Map([[0, null]]); // tslint:disable-line no-empty
|
|
189
|
+
const wrap = createBroker({
|
|
190
|
+
clearInterval: ({ call }) => {
|
|
191
|
+
return (timerId) => {
|
|
192
|
+
if (typeof scheduledIntervalsState.get(timerId) === 'symbol') {
|
|
193
|
+
scheduledIntervalsState.set(timerId, null);
|
|
194
|
+
call('clear', { timerId, timerType: 'interval' }).then(() => {
|
|
195
|
+
scheduledIntervalsState.delete(timerId);
|
|
216
196
|
});
|
|
217
197
|
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
198
|
+
};
|
|
199
|
+
},
|
|
200
|
+
clearTimeout: ({ call }) => {
|
|
201
|
+
return (timerId) => {
|
|
202
|
+
if (typeof scheduledTimeoutsState.get(timerId) === 'symbol') {
|
|
203
|
+
scheduledTimeoutsState.set(timerId, null);
|
|
204
|
+
call('clear', { timerId, timerType: 'timeout' }).then(() => {
|
|
205
|
+
scheduledTimeoutsState.delete(timerId);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
},
|
|
210
|
+
setInterval: ({ call }) => {
|
|
211
|
+
return (func, delay = 0, ...args) => {
|
|
212
|
+
const symbol = Symbol();
|
|
213
|
+
const timerId = generateUniqueNumber(scheduledIntervalsState);
|
|
214
|
+
scheduledIntervalsState.set(timerId, symbol);
|
|
215
|
+
const schedule = () => call('set', {
|
|
223
216
|
delay,
|
|
224
217
|
now: performance.timeOrigin + performance.now(),
|
|
225
218
|
timerId,
|
|
226
219
|
timerType: 'interval'
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
220
|
+
}).then(() => {
|
|
221
|
+
const state = scheduledIntervalsState.get(timerId);
|
|
222
|
+
if (state === undefined) {
|
|
223
|
+
throw new Error('The timer is in an undefined state.');
|
|
224
|
+
}
|
|
225
|
+
if (state === symbol) {
|
|
226
|
+
func(...args);
|
|
227
|
+
// Doublecheck if the interval should still be rescheduled because it could have been cleared inside of func().
|
|
228
|
+
if (scheduledIntervalsState.get(timerId) === symbol) {
|
|
229
|
+
schedule();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
schedule();
|
|
234
|
+
return timerId;
|
|
235
|
+
};
|
|
236
|
+
},
|
|
237
|
+
setTimeout: ({ call }) => {
|
|
238
|
+
return (func, delay = 0, ...args) => {
|
|
239
|
+
const symbol = Symbol();
|
|
240
|
+
const timerId = generateUniqueNumber(scheduledTimeoutsState);
|
|
241
|
+
scheduledTimeoutsState.set(timerId, symbol);
|
|
242
|
+
call('set', {
|
|
238
243
|
delay,
|
|
239
244
|
now: performance.timeOrigin + performance.now(),
|
|
240
245
|
timerId,
|
|
241
246
|
timerType: 'timeout'
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
247
|
+
}).then(() => {
|
|
248
|
+
const state = scheduledTimeoutsState.get(timerId);
|
|
249
|
+
if (state === undefined) {
|
|
250
|
+
throw new Error('The timer is in an undefined state.');
|
|
251
|
+
}
|
|
252
|
+
if (state === symbol) {
|
|
253
|
+
// A timeout can be savely deleted because it is only called once.
|
|
254
|
+
scheduledTimeoutsState.delete(timerId);
|
|
255
|
+
func(...args);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
return timerId;
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
const load = (url) => {
|
|
263
|
+
const worker = new Worker(url);
|
|
264
|
+
return wrap(worker);
|
|
252
265
|
};
|
|
253
266
|
|
|
254
267
|
const createLoadOrReturnBroker = (loadBroker, worker) => {
|
|
@@ -267,7 +280,7 @@ define((function () { 'use strict';
|
|
|
267
280
|
};
|
|
268
281
|
|
|
269
282
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
270
|
-
const worker = `(()=>{"use strict";
|
|
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
|
|
271
284
|
|
|
272
285
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
273
286
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -589,8 +602,7 @@ define((function () { 'use strict';
|
|
|
589
602
|
: event.target;
|
|
590
603
|
let totalParent = elementItem;
|
|
591
604
|
if (DOMUtilsCommonUtils.isWin(totalParent)) {
|
|
592
|
-
if (totalParent ===
|
|
593
|
-
DOMUtilsContext.windowApi.document) {
|
|
605
|
+
if (totalParent === DOMUtilsContext.windowApi.document) {
|
|
594
606
|
totalParent = DOMUtilsContext.windowApi.document.documentElement;
|
|
595
607
|
}
|
|
596
608
|
}
|
|
@@ -658,8 +670,7 @@ define((function () { 'use strict';
|
|
|
658
670
|
if (typeof currentParam === "boolean") {
|
|
659
671
|
option.capture = currentParam;
|
|
660
672
|
}
|
|
661
|
-
else if (typeof currentParam === "object" &&
|
|
662
|
-
"capture" in currentParam) {
|
|
673
|
+
else if (typeof currentParam === "object" && "capture" in currentParam) {
|
|
663
674
|
option.capture = currentParam.capture;
|
|
664
675
|
}
|
|
665
676
|
return option;
|
|
@@ -721,8 +732,7 @@ define((function () { 'use strict';
|
|
|
721
732
|
// 目标函数、事件名
|
|
722
733
|
isRemoveAll = true;
|
|
723
734
|
}
|
|
724
|
-
else if ((args.length === 3 && typeof args[2] === "string") ||
|
|
725
|
-
Array.isArray(args[2])) {
|
|
735
|
+
else if ((args.length === 3 && typeof args[2] === "string") || Array.isArray(args[2])) {
|
|
726
736
|
// 目标函数、事件名、子元素选择器
|
|
727
737
|
isRemoveAll = true;
|
|
728
738
|
}
|
|
@@ -737,9 +747,7 @@ define((function () { 'use strict';
|
|
|
737
747
|
for (let index = 0; index < handlers.length; index++) {
|
|
738
748
|
let handler = handlers[index];
|
|
739
749
|
let flag = true;
|
|
740
|
-
if (flag &&
|
|
741
|
-
listenerCallBack &&
|
|
742
|
-
handler.originCallBack !== listenerCallBack) {
|
|
750
|
+
if (flag && listenerCallBack && handler.originCallBack !== listenerCallBack) {
|
|
743
751
|
// callback不同
|
|
744
752
|
flag = false;
|
|
745
753
|
}
|
|
@@ -799,9 +807,7 @@ define((function () { 'use strict';
|
|
|
799
807
|
return;
|
|
800
808
|
}
|
|
801
809
|
let elementEvents = elementItem[symbolEvents] || {};
|
|
802
|
-
let iterEventNameList = eventTypeList.length
|
|
803
|
-
? eventTypeList
|
|
804
|
-
: Object.keys(elementEvents);
|
|
810
|
+
let iterEventNameList = eventTypeList.length ? eventTypeList : Object.keys(elementEvents);
|
|
805
811
|
iterEventNameList.forEach((eventName) => {
|
|
806
812
|
let handlers = elementEvents[eventName];
|
|
807
813
|
if (!handlers) {
|
|
@@ -838,8 +844,7 @@ define((function () { 'use strict';
|
|
|
838
844
|
try {
|
|
839
845
|
if (DOMUtilsContext.windowApi.document.readyState === "complete" ||
|
|
840
846
|
(DOMUtilsContext.windowApi.document.readyState !== "loading" &&
|
|
841
|
-
!DOMUtilsContext.windowApi.document.documentElement
|
|
842
|
-
.doScroll)) {
|
|
847
|
+
!DOMUtilsContext.windowApi.document.documentElement.doScroll)) {
|
|
843
848
|
return true;
|
|
844
849
|
}
|
|
845
850
|
else {
|
|
@@ -1474,7 +1479,7 @@ define((function () { 'use strict';
|
|
|
1474
1479
|
super(option);
|
|
1475
1480
|
}
|
|
1476
1481
|
/** 版本号 */
|
|
1477
|
-
version = "2025.
|
|
1482
|
+
version = "2025.8.9";
|
|
1478
1483
|
attr(element, attrName, attrValue) {
|
|
1479
1484
|
let DOMUtilsContext = this;
|
|
1480
1485
|
if (typeof element === "string") {
|
|
@@ -1568,15 +1573,7 @@ define((function () { 'use strict';
|
|
|
1568
1573
|
* 把纯数字没有px的加上
|
|
1569
1574
|
*/
|
|
1570
1575
|
function handlePixe(propertyName, propertyValue) {
|
|
1571
|
-
let allowAddPixe = [
|
|
1572
|
-
"width",
|
|
1573
|
-
"height",
|
|
1574
|
-
"top",
|
|
1575
|
-
"left",
|
|
1576
|
-
"right",
|
|
1577
|
-
"bottom",
|
|
1578
|
-
"font-size",
|
|
1579
|
-
];
|
|
1576
|
+
let allowAddPixe = ["width", "height", "top", "left", "right", "bottom", "font-size"];
|
|
1580
1577
|
if (typeof propertyValue === "number") {
|
|
1581
1578
|
propertyValue = propertyValue.toString();
|
|
1582
1579
|
}
|
|
@@ -1618,8 +1615,7 @@ define((function () { 'use strict';
|
|
|
1618
1615
|
return;
|
|
1619
1616
|
}
|
|
1620
1617
|
let setStyleProperty = (propertyName, propertyValue) => {
|
|
1621
|
-
if (typeof propertyValue === "string" &&
|
|
1622
|
-
propertyValue.trim().endsWith("!important")) {
|
|
1618
|
+
if (typeof propertyValue === "string" && propertyValue.trim().endsWith("!important")) {
|
|
1623
1619
|
propertyValue = propertyValue
|
|
1624
1620
|
.trim()
|
|
1625
1621
|
.replace(/!important$/gi, "")
|
|
@@ -1633,9 +1629,7 @@ define((function () { 'use strict';
|
|
|
1633
1629
|
};
|
|
1634
1630
|
if (typeof property === "string") {
|
|
1635
1631
|
if (value == null) {
|
|
1636
|
-
return DOMUtilsContext.windowApi.globalThis
|
|
1637
|
-
.getComputedStyle(element)
|
|
1638
|
-
.getPropertyValue(property);
|
|
1632
|
+
return DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).getPropertyValue(property);
|
|
1639
1633
|
}
|
|
1640
1634
|
else {
|
|
1641
1635
|
setStyleProperty(property, value);
|
|
@@ -1738,12 +1732,8 @@ define((function () { 'use strict';
|
|
|
1738
1732
|
return transformInfo;
|
|
1739
1733
|
}
|
|
1740
1734
|
let elementTransform = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).transform;
|
|
1741
|
-
if (elementTransform != null &&
|
|
1742
|
-
|
|
1743
|
-
elementTransform !== "") {
|
|
1744
|
-
let elementTransformSplit = elementTransform
|
|
1745
|
-
.match(/\((.+)\)/)?.[1]
|
|
1746
|
-
.split(",");
|
|
1735
|
+
if (elementTransform != null && elementTransform !== "none" && elementTransform !== "") {
|
|
1736
|
+
let elementTransformSplit = elementTransform.match(/\((.+)\)/)?.[1].split(",");
|
|
1747
1737
|
if (elementTransformSplit) {
|
|
1748
1738
|
transform_left = Math.abs(parseInt(elementTransformSplit[4]));
|
|
1749
1739
|
transform_top = Math.abs(parseInt(elementTransformSplit[5]));
|
|
@@ -1781,8 +1771,7 @@ define((function () { 'use strict';
|
|
|
1781
1771
|
}
|
|
1782
1772
|
if (value == null) {
|
|
1783
1773
|
// 获取
|
|
1784
|
-
if (element.localName === "input" &&
|
|
1785
|
-
(element.type === "checkbox" || element.type === "radio")) {
|
|
1774
|
+
if (element.localName === "input" && (element.type === "checkbox" || element.type === "radio")) {
|
|
1786
1775
|
return element.checked;
|
|
1787
1776
|
}
|
|
1788
1777
|
else {
|
|
@@ -1791,8 +1780,7 @@ define((function () { 'use strict';
|
|
|
1791
1780
|
}
|
|
1792
1781
|
else {
|
|
1793
1782
|
// 设置
|
|
1794
|
-
if (element.localName === "input" &&
|
|
1795
|
-
(element.type === "checkbox" || element.type === "radio")) {
|
|
1783
|
+
if (element.localName === "input" && (element.type === "checkbox" || element.type === "radio")) {
|
|
1796
1784
|
element.checked = !!value;
|
|
1797
1785
|
}
|
|
1798
1786
|
else {
|
|
@@ -2046,7 +2034,15 @@ define((function () { 'use strict';
|
|
|
2046
2034
|
}
|
|
2047
2035
|
function elementAppendChild(ele, text) {
|
|
2048
2036
|
if (typeof content === "string") {
|
|
2049
|
-
ele
|
|
2037
|
+
if (ele instanceof DocumentFragment) {
|
|
2038
|
+
if (typeof text === "string") {
|
|
2039
|
+
text = DOMUtilsContext.parseHTML(text, true, false);
|
|
2040
|
+
}
|
|
2041
|
+
ele.appendChild(text);
|
|
2042
|
+
}
|
|
2043
|
+
else {
|
|
2044
|
+
ele.insertAdjacentHTML("beforeend", DOMUtilsCommonUtils.getSafeHTML(text));
|
|
2045
|
+
}
|
|
2050
2046
|
}
|
|
2051
2047
|
else {
|
|
2052
2048
|
ele.appendChild(text);
|
|
@@ -2057,6 +2053,7 @@ define((function () { 'use strict';
|
|
|
2057
2053
|
let fragment = DOMUtilsContext.windowApi.document.createDocumentFragment();
|
|
2058
2054
|
content.forEach((ele) => {
|
|
2059
2055
|
if (typeof ele === "string") {
|
|
2056
|
+
// 转为元素
|
|
2060
2057
|
ele = DOMUtilsContext.parseHTML(ele, true, false);
|
|
2061
2058
|
}
|
|
2062
2059
|
fragment.appendChild(ele);
|
|
@@ -2092,7 +2089,13 @@ define((function () { 'use strict';
|
|
|
2092
2089
|
return;
|
|
2093
2090
|
}
|
|
2094
2091
|
if (typeof content === "string") {
|
|
2095
|
-
element
|
|
2092
|
+
if (element instanceof DocumentFragment) {
|
|
2093
|
+
content = DOMUtilsContext.parseHTML(content, true, false);
|
|
2094
|
+
element.prepend(content);
|
|
2095
|
+
}
|
|
2096
|
+
else {
|
|
2097
|
+
element.insertAdjacentHTML("afterbegin", DOMUtilsCommonUtils.getSafeHTML(content));
|
|
2098
|
+
}
|
|
2096
2099
|
}
|
|
2097
2100
|
else {
|
|
2098
2101
|
let $firstChild = element.firstChild;
|
|
@@ -2265,16 +2268,14 @@ define((function () { 'use strict';
|
|
|
2265
2268
|
return;
|
|
2266
2269
|
}
|
|
2267
2270
|
if (DOMUtilsCommonUtils.isWin(element)) {
|
|
2268
|
-
return DOMUtilsContext.windowApi.window.document.documentElement
|
|
2269
|
-
.clientWidth;
|
|
2271
|
+
return DOMUtilsContext.windowApi.window.document.documentElement.clientWidth;
|
|
2270
2272
|
}
|
|
2271
2273
|
if (element.nodeType === 9) {
|
|
2272
2274
|
/* Document文档节点 */
|
|
2273
2275
|
element = element;
|
|
2274
2276
|
return Math.max(element.body.scrollWidth, element.documentElement.scrollWidth, element.body.offsetWidth, element.documentElement.offsetWidth, element.documentElement.clientWidth);
|
|
2275
2277
|
}
|
|
2276
|
-
if (isShow ||
|
|
2277
|
-
(!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2278
|
+
if (isShow || (!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2278
2279
|
/* 已显示 */
|
|
2279
2280
|
/* 不从style中获取对应的宽度,因为可能使用了class定义了width !important */
|
|
2280
2281
|
element = element;
|
|
@@ -2309,8 +2310,7 @@ define((function () { 'use strict';
|
|
|
2309
2310
|
height(element, isShow = false) {
|
|
2310
2311
|
let DOMUtilsContext = this;
|
|
2311
2312
|
if (DOMUtilsCommonUtils.isWin(element)) {
|
|
2312
|
-
return DOMUtilsContext.windowApi.window.document.documentElement
|
|
2313
|
-
.clientHeight;
|
|
2313
|
+
return DOMUtilsContext.windowApi.window.document.documentElement.clientHeight;
|
|
2314
2314
|
}
|
|
2315
2315
|
if (typeof element === "string") {
|
|
2316
2316
|
element = DOMUtilsContext.selector(element);
|
|
@@ -2324,8 +2324,7 @@ define((function () { 'use strict';
|
|
|
2324
2324
|
/* Document文档节点 */
|
|
2325
2325
|
return Math.max(element.body.scrollHeight, element.documentElement.scrollHeight, element.body.offsetHeight, element.documentElement.offsetHeight, element.documentElement.clientHeight);
|
|
2326
2326
|
}
|
|
2327
|
-
if (isShow ||
|
|
2328
|
-
(!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2327
|
+
if (isShow || (!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2329
2328
|
element = element;
|
|
2330
2329
|
/* 已显示 */
|
|
2331
2330
|
/* 从style中获取对应的高度,因为可能使用了class定义了width !important */
|
|
@@ -2439,10 +2438,10 @@ define((function () { 'use strict';
|
|
|
2439
2438
|
if (typeof duration !== "number" || duration <= 0) {
|
|
2440
2439
|
throw new TypeError("duration must be a positive number");
|
|
2441
2440
|
}
|
|
2442
|
-
if (typeof callback !== "function" && callback !==
|
|
2441
|
+
if (typeof callback !== "function" && callback !== void 0) {
|
|
2443
2442
|
throw new TypeError("callback must be a function or null");
|
|
2444
2443
|
}
|
|
2445
|
-
if (typeof styles !== "object" || styles ===
|
|
2444
|
+
if (typeof styles !== "object" || styles === void 0) {
|
|
2446
2445
|
throw new TypeError("styles must be an object");
|
|
2447
2446
|
}
|
|
2448
2447
|
if (Object.keys(styles).length === 0) {
|
|
@@ -2453,8 +2452,7 @@ define((function () { 'use strict';
|
|
|
2453
2452
|
let to = {};
|
|
2454
2453
|
for (let prop in styles) {
|
|
2455
2454
|
from[prop] =
|
|
2456
|
-
element.style[prop] ||
|
|
2457
|
-
DOMUtilsContext.windowApi.globalThis.getComputedStyle(element)[prop];
|
|
2455
|
+
element.style[prop] || DOMUtilsContext.windowApi.globalThis.getComputedStyle(element)[prop];
|
|
2458
2456
|
to[prop] = styles[prop];
|
|
2459
2457
|
}
|
|
2460
2458
|
let timer = DOMUtilsCommonUtils.setInterval(function () {
|
|
@@ -2464,8 +2462,7 @@ define((function () { 'use strict';
|
|
|
2464
2462
|
progress = 1;
|
|
2465
2463
|
}
|
|
2466
2464
|
for (let prop in styles) {
|
|
2467
|
-
element.style[prop] =
|
|
2468
|
-
from[prop] + (to[prop] - from[prop]) * progress + "px";
|
|
2465
|
+
element.style[prop] = from[prop] + (to[prop] - from[prop]) * progress + "px";
|
|
2469
2466
|
}
|
|
2470
2467
|
if (progress === 1) {
|
|
2471
2468
|
DOMUtilsCommonUtils.clearInterval(timer);
|
|
@@ -2550,8 +2547,7 @@ define((function () { 'use strict';
|
|
|
2550
2547
|
if (element == null) {
|
|
2551
2548
|
return;
|
|
2552
2549
|
}
|
|
2553
|
-
return Array.from(element.parentElement
|
|
2554
|
-
.children).filter((child) => child !== element);
|
|
2550
|
+
return Array.from(element.parentElement.children).filter((child) => child !== element);
|
|
2555
2551
|
}
|
|
2556
2552
|
/**
|
|
2557
2553
|
* 获取当前元素的父元素
|
|
@@ -2627,14 +2623,7 @@ define((function () { 'use strict';
|
|
|
2627
2623
|
if (element.name &&
|
|
2628
2624
|
!element.disabled &&
|
|
2629
2625
|
(element.checked ||
|
|
2630
|
-
[
|
|
2631
|
-
"text",
|
|
2632
|
-
"hidden",
|
|
2633
|
-
"password",
|
|
2634
|
-
"textarea",
|
|
2635
|
-
"select-one",
|
|
2636
|
-
"select-multiple",
|
|
2637
|
-
].includes(element.type))) {
|
|
2626
|
+
["text", "hidden", "password", "textarea", "select-one", "select-multiple"].includes(element.type))) {
|
|
2638
2627
|
if (element.type === "select-multiple") {
|
|
2639
2628
|
for (let j = 0; j < element.options.length; j++) {
|
|
2640
2629
|
if (element.options[j].selected) {
|
|
@@ -2854,9 +2843,7 @@ define((function () { 'use strict';
|
|
|
2854
2843
|
});
|
|
2855
2844
|
return;
|
|
2856
2845
|
}
|
|
2857
|
-
if (DOMUtilsContext.windowApi.globalThis
|
|
2858
|
-
.getComputedStyle(element)
|
|
2859
|
-
.getPropertyValue("display") === "none") {
|
|
2846
|
+
if (DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).getPropertyValue("display") === "none") {
|
|
2860
2847
|
DOMUtilsContext.show(element, checkVisiblie);
|
|
2861
2848
|
}
|
|
2862
2849
|
else {
|
|
@@ -2901,9 +2888,7 @@ define((function () { 'use strict';
|
|
|
2901
2888
|
selectionStart = Math.min($input.value.length, selectionStart);
|
|
2902
2889
|
if (typeof selectionEnd == "string")
|
|
2903
2890
|
selectionEnd = parseFloat(selectionEnd);
|
|
2904
|
-
if (typeof selectionEnd != "number" ||
|
|
2905
|
-
isNaN(selectionEnd) ||
|
|
2906
|
-
selectionEnd < selectionStart) {
|
|
2891
|
+
if (typeof selectionEnd != "number" || isNaN(selectionEnd) || selectionEnd < selectionStart) {
|
|
2907
2892
|
selectionEnd = selectionStart;
|
|
2908
2893
|
}
|
|
2909
2894
|
if (selectionEnd < 0)
|
|
@@ -2990,11 +2975,7 @@ define((function () { 'use strict';
|
|
|
2990
2975
|
var isBoxModel = $box.offsetWidth == 2;
|
|
2991
2976
|
body.removeChild($box);
|
|
2992
2977
|
let $boxRect = $input.getBoundingClientRect();
|
|
2993
|
-
var clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, scrollTop = win.pageYOffset ||
|
|
2994
|
-
(isBoxModel && docElem.scrollTop) ||
|
|
2995
|
-
body.scrollTop, scrollLeft = win.pageXOffset ||
|
|
2996
|
-
(isBoxModel && docElem.scrollLeft) ||
|
|
2997
|
-
body.scrollLeft;
|
|
2978
|
+
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;
|
|
2998
2979
|
return {
|
|
2999
2980
|
top: $boxRect.top + scrollTop - clientTop,
|
|
3000
2981
|
left: $boxRect.left + scrollLeft - clientLeft,
|