@whitesev/domutils 1.8.1 → 1.8.3

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 CHANGED
@@ -292,9 +292,9 @@ define((function () { 'use strict';
292
292
  const worker = `(()=>{var e={455(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)},m=(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])})},f=new Map,h=d(globalThis.clearTimeout,f),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=m(f,performance,globalThis.setTimeout,w),T=m(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
293
293
 
294
294
  const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
295
- const clearInterval$1 = (timerId) => loadOrReturnBroker().clearInterval(timerId);
296
- const clearTimeout$1 = (timerId) => loadOrReturnBroker().clearTimeout(timerId);
297
- const setInterval$1 = (...args) => loadOrReturnBroker().setInterval(...args);
295
+ const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
296
+ const clearTimeout = (timerId) => loadOrReturnBroker().clearTimeout(timerId);
297
+ const setInterval = (...args) => loadOrReturnBroker().setInterval(...args);
298
298
  const setTimeout$1 = (...args) => loadOrReturnBroker().setTimeout(...args);
299
299
 
300
300
  /** 通用工具类 */
@@ -303,10 +303,10 @@ define((function () { 'use strict';
303
303
  document: document,
304
304
  window: window,
305
305
  top: top,
306
- setTimeout: setTimeout,
307
- clearTimeout: clearTimeout,
308
- setInterval: setInterval,
309
- clearInterval: clearInterval,
306
+ setTimeout: globalThis.setTimeout.bind(globalThis),
307
+ clearTimeout: globalThis.clearTimeout.bind(globalThis),
308
+ setInterval: globalThis.setInterval.bind(globalThis),
309
+ clearInterval: globalThis.clearInterval.bind(globalThis),
310
310
  }),
311
311
  /**
312
312
  * 判断元素是否已显示或已连接
@@ -463,7 +463,7 @@ define((function () { 'use strict';
463
463
  clearTimeout(timeId) {
464
464
  try {
465
465
  if (timeId != null) {
466
- clearTimeout$1(timeId);
466
+ clearTimeout(timeId);
467
467
  }
468
468
  }
469
469
  catch {
@@ -478,7 +478,7 @@ define((function () { 'use strict';
478
478
  */
479
479
  setInterval(callback, timeout = 0) {
480
480
  try {
481
- return setInterval$1(callback, timeout);
481
+ return setInterval(callback, timeout);
482
482
  }
483
483
  catch {
484
484
  return this.windowApi.setInterval(callback, timeout);
@@ -490,7 +490,7 @@ define((function () { 'use strict';
490
490
  clearInterval(timeId) {
491
491
  try {
492
492
  if (timeId != null) {
493
- clearInterval$1(timeId);
493
+ clearInterval(timeId);
494
494
  }
495
495
  }
496
496
  catch {
@@ -517,7 +517,7 @@ define((function () { 'use strict';
517
517
  },
518
518
  };
519
519
 
520
- const version = "1.8.1";
520
+ const version = "1.8.3";
521
521
 
522
522
  class ElementSelector {
523
523
  windowApi;
@@ -2611,6 +2611,8 @@ define((function () { 'use strict';
2611
2611
  let timer = void 0;
2612
2612
  /** 是否是移动端点击 */
2613
2613
  let isMobileTouch = false;
2614
+ /** 检测是否是单击的延迟时间 */
2615
+ const checkClickTime = 200;
2614
2616
  const dblclick_handler = async (evt, option) => {
2615
2617
  if (evt.type === "dblclick" && isMobileTouch) {
2616
2618
  // 禁止在移动端触发dblclick事件
@@ -2619,12 +2621,16 @@ define((function () { 'use strict';
2619
2621
  await handler(evt, option);
2620
2622
  };
2621
2623
  const dblClickListener = this.on($el, "dblclick", (evt) => {
2624
+ this.preventEvent(evt);
2622
2625
  dblclick_handler(evt, {
2623
2626
  isDoubleClick: true,
2624
2627
  });
2625
2628
  }, options);
2626
- const touchEndListener = this.on($el, "touchend", selector, (evt, selectorTarget) => {
2627
- isMobileTouch = true;
2629
+ const touchEndListener = this.on($el, "pointerup", selector, (evt, selectorTarget) => {
2630
+ this.preventEvent(evt);
2631
+ if (evt.pointerType === "touch") {
2632
+ isMobileTouch = true;
2633
+ }
2628
2634
  CommonUtils.clearTimeout(timer);
2629
2635
  timer = void 0;
2630
2636
  if (isDoubleClick && $click === selectorTarget) {
@@ -2642,7 +2648,7 @@ define((function () { 'use strict';
2642
2648
  dblclick_handler(evt, {
2643
2649
  isDoubleClick: false,
2644
2650
  });
2645
- }, 200);
2651
+ }, checkClickTime);
2646
2652
  isDoubleClick = true;
2647
2653
  $click = selectorTarget;
2648
2654
  }