@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.system.js
CHANGED
|
@@ -103,155 +103,168 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
103
103
|
const cache = createCache(LAST_NUMBER_WEAK_MAP);
|
|
104
104
|
const generateUniqueNumber = createGenerateUniqueNumber(cache, LAST_NUMBER_WEAK_MAP);
|
|
105
105
|
|
|
106
|
-
const
|
|
107
|
-
return
|
|
106
|
+
const isMessagePort = (sender) => {
|
|
107
|
+
return typeof sender.start === 'function';
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
-
const
|
|
111
|
-
return typeof message.id === 'number' && typeof message.result === 'boolean';
|
|
112
|
-
};
|
|
110
|
+
const PORT_MAP = new WeakMap();
|
|
113
111
|
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const timerIdAndTimerType = unrespondedRequests.get(idOrFunc);
|
|
130
|
-
if (timerIdAndTimerType === undefined ||
|
|
131
|
-
timerIdAndTimerType.timerId !== timerId ||
|
|
132
|
-
timerIdAndTimerType.timerType !== timerType) {
|
|
133
|
-
throw new Error('The timer is in an undefined state.');
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
else if (typeof idOrFunc === 'function') {
|
|
137
|
-
idOrFunc();
|
|
138
|
-
}
|
|
112
|
+
const extendBrokerImplementation = (partialBrokerImplementation) => ({
|
|
113
|
+
...partialBrokerImplementation,
|
|
114
|
+
connect: ({ call }) => {
|
|
115
|
+
return async () => {
|
|
116
|
+
const { port1, port2 } = new MessageChannel();
|
|
117
|
+
const portId = await call('connect', { port: port1 }, [port1]);
|
|
118
|
+
PORT_MAP.set(port2, portId);
|
|
119
|
+
return port2;
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
disconnect: ({ call }) => {
|
|
123
|
+
return async (port) => {
|
|
124
|
+
const portId = PORT_MAP.get(port);
|
|
125
|
+
if (portId === undefined) {
|
|
126
|
+
throw new Error('The given port is not connected.');
|
|
139
127
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
128
|
+
await call('disconnect', { portId });
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
isSupported: ({ call }) => {
|
|
132
|
+
return () => call('isSupported');
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const ONGOING_REQUESTS = new WeakMap();
|
|
137
|
+
const createOrGetOngoingRequests = (sender) => {
|
|
138
|
+
if (ONGOING_REQUESTS.has(sender)) {
|
|
139
|
+
// @todo TypeScript needs to be convinced that has() works as expected.
|
|
140
|
+
return ONGOING_REQUESTS.get(sender);
|
|
141
|
+
}
|
|
142
|
+
const ongoingRequests = new Map();
|
|
143
|
+
ONGOING_REQUESTS.set(sender, ongoingRequests);
|
|
144
|
+
return ongoingRequests;
|
|
145
|
+
};
|
|
146
|
+
const createBroker = (brokerImplementation) => {
|
|
147
|
+
const fullBrokerImplementation = extendBrokerImplementation(brokerImplementation);
|
|
148
|
+
return (sender) => {
|
|
149
|
+
const ongoingRequests = createOrGetOngoingRequests(sender);
|
|
150
|
+
sender.addEventListener('message', (({ data: message }) => {
|
|
151
|
+
const { id } = message;
|
|
152
|
+
if (id !== null && ongoingRequests.has(id)) {
|
|
153
|
+
const { reject, resolve } = ongoingRequests.get(id);
|
|
154
|
+
ongoingRequests.delete(id);
|
|
155
|
+
if (message.error === undefined) {
|
|
156
|
+
resolve(message.result);
|
|
152
157
|
}
|
|
153
|
-
else
|
|
154
|
-
|
|
155
|
-
// A timeout can be savely deleted because it is only called once.
|
|
156
|
-
scheduledTimeoutFunctions.delete(timerId);
|
|
158
|
+
else {
|
|
159
|
+
reject(new Error(message.error.message));
|
|
157
160
|
}
|
|
158
161
|
}
|
|
162
|
+
}));
|
|
163
|
+
if (isMessagePort(sender)) {
|
|
164
|
+
sender.start();
|
|
159
165
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
scheduledTimeoutFunctions.delete(timerId);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
const { error: { message } } = data;
|
|
177
|
-
throw new Error(message);
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
const clearInterval = (timerId) => {
|
|
181
|
-
if (typeof scheduledIntervalFunctions.get(timerId) === 'function') {
|
|
182
|
-
const id = generateUniqueNumber(unrespondedRequests);
|
|
183
|
-
unrespondedRequests.set(id, { timerId, timerType: 'interval' });
|
|
184
|
-
scheduledIntervalFunctions.set(timerId, id);
|
|
185
|
-
worker.postMessage({
|
|
186
|
-
id,
|
|
187
|
-
method: 'clear',
|
|
188
|
-
params: { timerId, timerType: 'interval' }
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
const clearTimeout = (timerId) => {
|
|
193
|
-
if (typeof scheduledTimeoutFunctions.get(timerId) === 'function') {
|
|
194
|
-
const id = generateUniqueNumber(unrespondedRequests);
|
|
195
|
-
unrespondedRequests.set(id, { timerId, timerType: 'timeout' });
|
|
196
|
-
scheduledTimeoutFunctions.set(timerId, id);
|
|
197
|
-
worker.postMessage({
|
|
198
|
-
id,
|
|
199
|
-
method: 'clear',
|
|
200
|
-
params: { timerId, timerType: 'timeout' }
|
|
166
|
+
const call = (method, params = null, transferables = []) => {
|
|
167
|
+
return new Promise((resolve, reject) => {
|
|
168
|
+
const id = generateUniqueNumber(ongoingRequests);
|
|
169
|
+
ongoingRequests.set(id, { reject, resolve });
|
|
170
|
+
if (params === null) {
|
|
171
|
+
sender.postMessage({ id, method }, transferables);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
sender.postMessage({ id, method, params }, transferables);
|
|
175
|
+
}
|
|
201
176
|
});
|
|
177
|
+
};
|
|
178
|
+
const notify = (method, params, transferables = []) => {
|
|
179
|
+
sender.postMessage({ id: null, method, params }, transferables);
|
|
180
|
+
};
|
|
181
|
+
let functions = {};
|
|
182
|
+
for (const [key, handler] of Object.entries(fullBrokerImplementation)) {
|
|
183
|
+
functions = { ...functions, [key]: handler({ call, notify }) };
|
|
202
184
|
}
|
|
185
|
+
return { ...functions };
|
|
203
186
|
};
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
timerId,
|
|
217
|
-
timerType: 'interval'
|
|
218
|
-
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// Prefilling the Maps with a function indexed by zero is necessary to be compliant with the specification.
|
|
190
|
+
const scheduledIntervalsState = new Map([[0, null]]); // tslint:disable-line no-empty
|
|
191
|
+
const scheduledTimeoutsState = new Map([[0, null]]); // tslint:disable-line no-empty
|
|
192
|
+
const wrap = createBroker({
|
|
193
|
+
clearInterval: ({ call }) => {
|
|
194
|
+
return (timerId) => {
|
|
195
|
+
if (typeof scheduledIntervalsState.get(timerId) === 'symbol') {
|
|
196
|
+
scheduledIntervalsState.set(timerId, null);
|
|
197
|
+
call('clear', { timerId, timerType: 'interval' }).then(() => {
|
|
198
|
+
scheduledIntervalsState.delete(timerId);
|
|
219
199
|
});
|
|
220
200
|
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
201
|
+
};
|
|
202
|
+
},
|
|
203
|
+
clearTimeout: ({ call }) => {
|
|
204
|
+
return (timerId) => {
|
|
205
|
+
if (typeof scheduledTimeoutsState.get(timerId) === 'symbol') {
|
|
206
|
+
scheduledTimeoutsState.set(timerId, null);
|
|
207
|
+
call('clear', { timerId, timerType: 'timeout' }).then(() => {
|
|
208
|
+
scheduledTimeoutsState.delete(timerId);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
},
|
|
213
|
+
setInterval: ({ call }) => {
|
|
214
|
+
return (func, delay = 0, ...args) => {
|
|
215
|
+
const symbol = Symbol();
|
|
216
|
+
const timerId = generateUniqueNumber(scheduledIntervalsState);
|
|
217
|
+
scheduledIntervalsState.set(timerId, symbol);
|
|
218
|
+
const schedule = () => call('set', {
|
|
226
219
|
delay,
|
|
227
220
|
now: performance.timeOrigin + performance.now(),
|
|
228
221
|
timerId,
|
|
229
222
|
timerType: 'interval'
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
223
|
+
}).then(() => {
|
|
224
|
+
const state = scheduledIntervalsState.get(timerId);
|
|
225
|
+
if (state === undefined) {
|
|
226
|
+
throw new Error('The timer is in an undefined state.');
|
|
227
|
+
}
|
|
228
|
+
if (state === symbol) {
|
|
229
|
+
func(...args);
|
|
230
|
+
// Doublecheck if the interval should still be rescheduled because it could have been cleared inside of func().
|
|
231
|
+
if (scheduledIntervalsState.get(timerId) === symbol) {
|
|
232
|
+
schedule();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
schedule();
|
|
237
|
+
return timerId;
|
|
238
|
+
};
|
|
239
|
+
},
|
|
240
|
+
setTimeout: ({ call }) => {
|
|
241
|
+
return (func, delay = 0, ...args) => {
|
|
242
|
+
const symbol = Symbol();
|
|
243
|
+
const timerId = generateUniqueNumber(scheduledTimeoutsState);
|
|
244
|
+
scheduledTimeoutsState.set(timerId, symbol);
|
|
245
|
+
call('set', {
|
|
241
246
|
delay,
|
|
242
247
|
now: performance.timeOrigin + performance.now(),
|
|
243
248
|
timerId,
|
|
244
249
|
timerType: 'timeout'
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
250
|
+
}).then(() => {
|
|
251
|
+
const state = scheduledTimeoutsState.get(timerId);
|
|
252
|
+
if (state === undefined) {
|
|
253
|
+
throw new Error('The timer is in an undefined state.');
|
|
254
|
+
}
|
|
255
|
+
if (state === symbol) {
|
|
256
|
+
// A timeout can be savely deleted because it is only called once.
|
|
257
|
+
scheduledTimeoutsState.delete(timerId);
|
|
258
|
+
func(...args);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
return timerId;
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
const load = (url) => {
|
|
266
|
+
const worker = new Worker(url);
|
|
267
|
+
return wrap(worker);
|
|
255
268
|
};
|
|
256
269
|
|
|
257
270
|
const createLoadOrReturnBroker = (loadBroker, worker) => {
|
|
@@ -270,7 +283,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
270
283
|
};
|
|
271
284
|
|
|
272
285
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
273
|
-
const worker = `(()=>{"use strict";
|
|
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
|
|
274
287
|
|
|
275
288
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
276
289
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -592,8 +605,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
592
605
|
: event.target;
|
|
593
606
|
let totalParent = elementItem;
|
|
594
607
|
if (DOMUtilsCommonUtils.isWin(totalParent)) {
|
|
595
|
-
if (totalParent ===
|
|
596
|
-
DOMUtilsContext.windowApi.document) {
|
|
608
|
+
if (totalParent === DOMUtilsContext.windowApi.document) {
|
|
597
609
|
totalParent = DOMUtilsContext.windowApi.document.documentElement;
|
|
598
610
|
}
|
|
599
611
|
}
|
|
@@ -661,8 +673,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
661
673
|
if (typeof currentParam === "boolean") {
|
|
662
674
|
option.capture = currentParam;
|
|
663
675
|
}
|
|
664
|
-
else if (typeof currentParam === "object" &&
|
|
665
|
-
"capture" in currentParam) {
|
|
676
|
+
else if (typeof currentParam === "object" && "capture" in currentParam) {
|
|
666
677
|
option.capture = currentParam.capture;
|
|
667
678
|
}
|
|
668
679
|
return option;
|
|
@@ -724,8 +735,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
724
735
|
// 目标函数、事件名
|
|
725
736
|
isRemoveAll = true;
|
|
726
737
|
}
|
|
727
|
-
else if ((args.length === 3 && typeof args[2] === "string") ||
|
|
728
|
-
Array.isArray(args[2])) {
|
|
738
|
+
else if ((args.length === 3 && typeof args[2] === "string") || Array.isArray(args[2])) {
|
|
729
739
|
// 目标函数、事件名、子元素选择器
|
|
730
740
|
isRemoveAll = true;
|
|
731
741
|
}
|
|
@@ -740,9 +750,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
740
750
|
for (let index = 0; index < handlers.length; index++) {
|
|
741
751
|
let handler = handlers[index];
|
|
742
752
|
let flag = true;
|
|
743
|
-
if (flag &&
|
|
744
|
-
listenerCallBack &&
|
|
745
|
-
handler.originCallBack !== listenerCallBack) {
|
|
753
|
+
if (flag && listenerCallBack && handler.originCallBack !== listenerCallBack) {
|
|
746
754
|
// callback不同
|
|
747
755
|
flag = false;
|
|
748
756
|
}
|
|
@@ -802,9 +810,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
802
810
|
return;
|
|
803
811
|
}
|
|
804
812
|
let elementEvents = elementItem[symbolEvents] || {};
|
|
805
|
-
let iterEventNameList = eventTypeList.length
|
|
806
|
-
? eventTypeList
|
|
807
|
-
: Object.keys(elementEvents);
|
|
813
|
+
let iterEventNameList = eventTypeList.length ? eventTypeList : Object.keys(elementEvents);
|
|
808
814
|
iterEventNameList.forEach((eventName) => {
|
|
809
815
|
let handlers = elementEvents[eventName];
|
|
810
816
|
if (!handlers) {
|
|
@@ -841,8 +847,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
841
847
|
try {
|
|
842
848
|
if (DOMUtilsContext.windowApi.document.readyState === "complete" ||
|
|
843
849
|
(DOMUtilsContext.windowApi.document.readyState !== "loading" &&
|
|
844
|
-
!DOMUtilsContext.windowApi.document.documentElement
|
|
845
|
-
.doScroll)) {
|
|
850
|
+
!DOMUtilsContext.windowApi.document.documentElement.doScroll)) {
|
|
846
851
|
return true;
|
|
847
852
|
}
|
|
848
853
|
else {
|
|
@@ -1477,7 +1482,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1477
1482
|
super(option);
|
|
1478
1483
|
}
|
|
1479
1484
|
/** 版本号 */
|
|
1480
|
-
version = "2025.
|
|
1485
|
+
version = "2025.8.9";
|
|
1481
1486
|
attr(element, attrName, attrValue) {
|
|
1482
1487
|
let DOMUtilsContext = this;
|
|
1483
1488
|
if (typeof element === "string") {
|
|
@@ -1571,15 +1576,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1571
1576
|
* 把纯数字没有px的加上
|
|
1572
1577
|
*/
|
|
1573
1578
|
function handlePixe(propertyName, propertyValue) {
|
|
1574
|
-
let allowAddPixe = [
|
|
1575
|
-
"width",
|
|
1576
|
-
"height",
|
|
1577
|
-
"top",
|
|
1578
|
-
"left",
|
|
1579
|
-
"right",
|
|
1580
|
-
"bottom",
|
|
1581
|
-
"font-size",
|
|
1582
|
-
];
|
|
1579
|
+
let allowAddPixe = ["width", "height", "top", "left", "right", "bottom", "font-size"];
|
|
1583
1580
|
if (typeof propertyValue === "number") {
|
|
1584
1581
|
propertyValue = propertyValue.toString();
|
|
1585
1582
|
}
|
|
@@ -1621,8 +1618,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1621
1618
|
return;
|
|
1622
1619
|
}
|
|
1623
1620
|
let setStyleProperty = (propertyName, propertyValue) => {
|
|
1624
|
-
if (typeof propertyValue === "string" &&
|
|
1625
|
-
propertyValue.trim().endsWith("!important")) {
|
|
1621
|
+
if (typeof propertyValue === "string" && propertyValue.trim().endsWith("!important")) {
|
|
1626
1622
|
propertyValue = propertyValue
|
|
1627
1623
|
.trim()
|
|
1628
1624
|
.replace(/!important$/gi, "")
|
|
@@ -1636,9 +1632,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1636
1632
|
};
|
|
1637
1633
|
if (typeof property === "string") {
|
|
1638
1634
|
if (value == null) {
|
|
1639
|
-
return DOMUtilsContext.windowApi.globalThis
|
|
1640
|
-
.getComputedStyle(element)
|
|
1641
|
-
.getPropertyValue(property);
|
|
1635
|
+
return DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).getPropertyValue(property);
|
|
1642
1636
|
}
|
|
1643
1637
|
else {
|
|
1644
1638
|
setStyleProperty(property, value);
|
|
@@ -1741,12 +1735,8 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1741
1735
|
return transformInfo;
|
|
1742
1736
|
}
|
|
1743
1737
|
let elementTransform = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).transform;
|
|
1744
|
-
if (elementTransform != null &&
|
|
1745
|
-
|
|
1746
|
-
elementTransform !== "") {
|
|
1747
|
-
let elementTransformSplit = elementTransform
|
|
1748
|
-
.match(/\((.+)\)/)?.[1]
|
|
1749
|
-
.split(",");
|
|
1738
|
+
if (elementTransform != null && elementTransform !== "none" && elementTransform !== "") {
|
|
1739
|
+
let elementTransformSplit = elementTransform.match(/\((.+)\)/)?.[1].split(",");
|
|
1750
1740
|
if (elementTransformSplit) {
|
|
1751
1741
|
transform_left = Math.abs(parseInt(elementTransformSplit[4]));
|
|
1752
1742
|
transform_top = Math.abs(parseInt(elementTransformSplit[5]));
|
|
@@ -1784,8 +1774,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1784
1774
|
}
|
|
1785
1775
|
if (value == null) {
|
|
1786
1776
|
// 获取
|
|
1787
|
-
if (element.localName === "input" &&
|
|
1788
|
-
(element.type === "checkbox" || element.type === "radio")) {
|
|
1777
|
+
if (element.localName === "input" && (element.type === "checkbox" || element.type === "radio")) {
|
|
1789
1778
|
return element.checked;
|
|
1790
1779
|
}
|
|
1791
1780
|
else {
|
|
@@ -1794,8 +1783,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1794
1783
|
}
|
|
1795
1784
|
else {
|
|
1796
1785
|
// 设置
|
|
1797
|
-
if (element.localName === "input" &&
|
|
1798
|
-
(element.type === "checkbox" || element.type === "radio")) {
|
|
1786
|
+
if (element.localName === "input" && (element.type === "checkbox" || element.type === "radio")) {
|
|
1799
1787
|
element.checked = !!value;
|
|
1800
1788
|
}
|
|
1801
1789
|
else {
|
|
@@ -2049,7 +2037,15 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2049
2037
|
}
|
|
2050
2038
|
function elementAppendChild(ele, text) {
|
|
2051
2039
|
if (typeof content === "string") {
|
|
2052
|
-
ele
|
|
2040
|
+
if (ele instanceof DocumentFragment) {
|
|
2041
|
+
if (typeof text === "string") {
|
|
2042
|
+
text = DOMUtilsContext.parseHTML(text, true, false);
|
|
2043
|
+
}
|
|
2044
|
+
ele.appendChild(text);
|
|
2045
|
+
}
|
|
2046
|
+
else {
|
|
2047
|
+
ele.insertAdjacentHTML("beforeend", DOMUtilsCommonUtils.getSafeHTML(text));
|
|
2048
|
+
}
|
|
2053
2049
|
}
|
|
2054
2050
|
else {
|
|
2055
2051
|
ele.appendChild(text);
|
|
@@ -2060,6 +2056,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2060
2056
|
let fragment = DOMUtilsContext.windowApi.document.createDocumentFragment();
|
|
2061
2057
|
content.forEach((ele) => {
|
|
2062
2058
|
if (typeof ele === "string") {
|
|
2059
|
+
// 转为元素
|
|
2063
2060
|
ele = DOMUtilsContext.parseHTML(ele, true, false);
|
|
2064
2061
|
}
|
|
2065
2062
|
fragment.appendChild(ele);
|
|
@@ -2095,7 +2092,13 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2095
2092
|
return;
|
|
2096
2093
|
}
|
|
2097
2094
|
if (typeof content === "string") {
|
|
2098
|
-
element
|
|
2095
|
+
if (element instanceof DocumentFragment) {
|
|
2096
|
+
content = DOMUtilsContext.parseHTML(content, true, false);
|
|
2097
|
+
element.prepend(content);
|
|
2098
|
+
}
|
|
2099
|
+
else {
|
|
2100
|
+
element.insertAdjacentHTML("afterbegin", DOMUtilsCommonUtils.getSafeHTML(content));
|
|
2101
|
+
}
|
|
2099
2102
|
}
|
|
2100
2103
|
else {
|
|
2101
2104
|
let $firstChild = element.firstChild;
|
|
@@ -2268,16 +2271,14 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2268
2271
|
return;
|
|
2269
2272
|
}
|
|
2270
2273
|
if (DOMUtilsCommonUtils.isWin(element)) {
|
|
2271
|
-
return DOMUtilsContext.windowApi.window.document.documentElement
|
|
2272
|
-
.clientWidth;
|
|
2274
|
+
return DOMUtilsContext.windowApi.window.document.documentElement.clientWidth;
|
|
2273
2275
|
}
|
|
2274
2276
|
if (element.nodeType === 9) {
|
|
2275
2277
|
/* Document文档节点 */
|
|
2276
2278
|
element = element;
|
|
2277
2279
|
return Math.max(element.body.scrollWidth, element.documentElement.scrollWidth, element.body.offsetWidth, element.documentElement.offsetWidth, element.documentElement.clientWidth);
|
|
2278
2280
|
}
|
|
2279
|
-
if (isShow ||
|
|
2280
|
-
(!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2281
|
+
if (isShow || (!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2281
2282
|
/* 已显示 */
|
|
2282
2283
|
/* 不从style中获取对应的宽度,因为可能使用了class定义了width !important */
|
|
2283
2284
|
element = element;
|
|
@@ -2312,8 +2313,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2312
2313
|
height(element, isShow = false) {
|
|
2313
2314
|
let DOMUtilsContext = this;
|
|
2314
2315
|
if (DOMUtilsCommonUtils.isWin(element)) {
|
|
2315
|
-
return DOMUtilsContext.windowApi.window.document.documentElement
|
|
2316
|
-
.clientHeight;
|
|
2316
|
+
return DOMUtilsContext.windowApi.window.document.documentElement.clientHeight;
|
|
2317
2317
|
}
|
|
2318
2318
|
if (typeof element === "string") {
|
|
2319
2319
|
element = DOMUtilsContext.selector(element);
|
|
@@ -2327,8 +2327,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2327
2327
|
/* Document文档节点 */
|
|
2328
2328
|
return Math.max(element.body.scrollHeight, element.documentElement.scrollHeight, element.body.offsetHeight, element.documentElement.offsetHeight, element.documentElement.clientHeight);
|
|
2329
2329
|
}
|
|
2330
|
-
if (isShow ||
|
|
2331
|
-
(!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2330
|
+
if (isShow || (!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2332
2331
|
element = element;
|
|
2333
2332
|
/* 已显示 */
|
|
2334
2333
|
/* 从style中获取对应的高度,因为可能使用了class定义了width !important */
|
|
@@ -2442,10 +2441,10 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2442
2441
|
if (typeof duration !== "number" || duration <= 0) {
|
|
2443
2442
|
throw new TypeError("duration must be a positive number");
|
|
2444
2443
|
}
|
|
2445
|
-
if (typeof callback !== "function" && callback !==
|
|
2444
|
+
if (typeof callback !== "function" && callback !== void 0) {
|
|
2446
2445
|
throw new TypeError("callback must be a function or null");
|
|
2447
2446
|
}
|
|
2448
|
-
if (typeof styles !== "object" || styles ===
|
|
2447
|
+
if (typeof styles !== "object" || styles === void 0) {
|
|
2449
2448
|
throw new TypeError("styles must be an object");
|
|
2450
2449
|
}
|
|
2451
2450
|
if (Object.keys(styles).length === 0) {
|
|
@@ -2456,8 +2455,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2456
2455
|
let to = {};
|
|
2457
2456
|
for (let prop in styles) {
|
|
2458
2457
|
from[prop] =
|
|
2459
|
-
element.style[prop] ||
|
|
2460
|
-
DOMUtilsContext.windowApi.globalThis.getComputedStyle(element)[prop];
|
|
2458
|
+
element.style[prop] || DOMUtilsContext.windowApi.globalThis.getComputedStyle(element)[prop];
|
|
2461
2459
|
to[prop] = styles[prop];
|
|
2462
2460
|
}
|
|
2463
2461
|
let timer = DOMUtilsCommonUtils.setInterval(function () {
|
|
@@ -2467,8 +2465,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2467
2465
|
progress = 1;
|
|
2468
2466
|
}
|
|
2469
2467
|
for (let prop in styles) {
|
|
2470
|
-
element.style[prop] =
|
|
2471
|
-
from[prop] + (to[prop] - from[prop]) * progress + "px";
|
|
2468
|
+
element.style[prop] = from[prop] + (to[prop] - from[prop]) * progress + "px";
|
|
2472
2469
|
}
|
|
2473
2470
|
if (progress === 1) {
|
|
2474
2471
|
DOMUtilsCommonUtils.clearInterval(timer);
|
|
@@ -2553,8 +2550,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2553
2550
|
if (element == null) {
|
|
2554
2551
|
return;
|
|
2555
2552
|
}
|
|
2556
|
-
return Array.from(element.parentElement
|
|
2557
|
-
.children).filter((child) => child !== element);
|
|
2553
|
+
return Array.from(element.parentElement.children).filter((child) => child !== element);
|
|
2558
2554
|
}
|
|
2559
2555
|
/**
|
|
2560
2556
|
* 获取当前元素的父元素
|
|
@@ -2630,14 +2626,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2630
2626
|
if (element.name &&
|
|
2631
2627
|
!element.disabled &&
|
|
2632
2628
|
(element.checked ||
|
|
2633
|
-
[
|
|
2634
|
-
"text",
|
|
2635
|
-
"hidden",
|
|
2636
|
-
"password",
|
|
2637
|
-
"textarea",
|
|
2638
|
-
"select-one",
|
|
2639
|
-
"select-multiple",
|
|
2640
|
-
].includes(element.type))) {
|
|
2629
|
+
["text", "hidden", "password", "textarea", "select-one", "select-multiple"].includes(element.type))) {
|
|
2641
2630
|
if (element.type === "select-multiple") {
|
|
2642
2631
|
for (let j = 0; j < element.options.length; j++) {
|
|
2643
2632
|
if (element.options[j].selected) {
|
|
@@ -2857,9 +2846,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2857
2846
|
});
|
|
2858
2847
|
return;
|
|
2859
2848
|
}
|
|
2860
|
-
if (DOMUtilsContext.windowApi.globalThis
|
|
2861
|
-
.getComputedStyle(element)
|
|
2862
|
-
.getPropertyValue("display") === "none") {
|
|
2849
|
+
if (DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).getPropertyValue("display") === "none") {
|
|
2863
2850
|
DOMUtilsContext.show(element, checkVisiblie);
|
|
2864
2851
|
}
|
|
2865
2852
|
else {
|
|
@@ -2904,9 +2891,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2904
2891
|
selectionStart = Math.min($input.value.length, selectionStart);
|
|
2905
2892
|
if (typeof selectionEnd == "string")
|
|
2906
2893
|
selectionEnd = parseFloat(selectionEnd);
|
|
2907
|
-
if (typeof selectionEnd != "number" ||
|
|
2908
|
-
isNaN(selectionEnd) ||
|
|
2909
|
-
selectionEnd < selectionStart) {
|
|
2894
|
+
if (typeof selectionEnd != "number" || isNaN(selectionEnd) || selectionEnd < selectionStart) {
|
|
2910
2895
|
selectionEnd = selectionStart;
|
|
2911
2896
|
}
|
|
2912
2897
|
if (selectionEnd < 0)
|
|
@@ -2993,11 +2978,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
2993
2978
|
var isBoxModel = $box.offsetWidth == 2;
|
|
2994
2979
|
body.removeChild($box);
|
|
2995
2980
|
let $boxRect = $input.getBoundingClientRect();
|
|
2996
|
-
var clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, scrollTop = win.pageYOffset ||
|
|
2997
|
-
(isBoxModel && docElem.scrollTop) ||
|
|
2998
|
-
body.scrollTop, scrollLeft = win.pageXOffset ||
|
|
2999
|
-
(isBoxModel && docElem.scrollLeft) ||
|
|
3000
|
-
body.scrollLeft;
|
|
2981
|
+
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;
|
|
3001
2982
|
return {
|
|
3002
2983
|
top: $boxRect.top + scrollTop - clientTop,
|
|
3003
2984
|
left: $boxRect.left + scrollLeft - clientLeft,
|