@whitesev/utils 1.4.3 → 1.4.4

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.
@@ -463,13 +463,14 @@ System.register('Utils', [], (function (exports) {
463
463
  /// <reference path="./index.d.ts" />
464
464
  // @name ajaxHooker
465
465
  // @author cxxjackie
466
- // @version 1.4.2
467
- // @updateLog 修复了fetch请求的参数为Request类型时body类型不正确的bug。
466
+ // @version 1.4.3
467
+ // @updateLog 修复特殊情况下有部分请求头丢失的问题。
468
+ // @updateLog xhr事件增加currentTarget劫持。
468
469
  // @supportURL https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
469
470
 
470
471
  const AjaxHooker = function () {
471
472
  return function() {
472
- const version = '1.4.2';
473
+ const version = '1.4.3';
473
474
  const hookInst = {
474
475
  hookFns: [],
475
476
  filters: []
@@ -724,6 +725,7 @@ System.register('Utils', [], (function (exports) {
724
725
  dispatchEvent(e) {
725
726
  e.stopImmediatePropagation = stopImmediatePropagation;
726
727
  defineProp(e, 'target', () => this.proxyXhr);
728
+ defineProp(e, 'currentTarget', () => this.proxyXhr);
727
729
  this.proxyEvents[e.type] && this.proxyEvents[e.type].forEach(fn => {
728
730
  this.resThenable.then(() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e));
729
731
  });
@@ -733,7 +735,7 @@ System.register('Utils', [], (function (exports) {
733
735
  }
734
736
  setRequestHeader(header, value) {
735
737
  this.originalXhr.setRequestHeader(header, value);
736
- if (this.originalXhr.readyState !== 1) return;
738
+ if (!this.request) return;
737
739
  const headers = this.request.headers;
738
740
  headers[header] = header in headers ? `${headers[header]}, ${value}` : value;
739
741
  }
@@ -3062,7 +3064,7 @@ System.register('Utils', [], (function (exports) {
3062
3064
  UtilsCore.init(option);
3063
3065
  }
3064
3066
  /** 版本号 */
3065
- version = "2024.6.11";
3067
+ version = "2024.6.14";
3066
3068
  addStyle(cssText) {
3067
3069
  if (typeof cssText !== "string") {
3068
3070
  throw new Error("Utils.addStyle 参数cssText 必须为String类型");