fetch-xhr-shim 1.0.2 → 1.0.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/cjs/event-system/EventP.js +6 -2
- package/dist/cjs/fetch-api/fetchP.js +1 -1
- package/dist/cjs/fixes.js +3 -3
- package/dist/cjs/utils.js +2 -2
- package/dist/esm/event-system/EventP.js +6 -2
- package/dist/esm/fetch-api/fetchP.js +1 -1
- package/dist/esm/fixes.js +3 -3
- package/dist/esm/utils.js +2 -2
- package/dist/fetch-xhr-shim.cjs.js +3440 -2448
- package/dist/fetch-xhr-shim.cjs.min.js +1 -1
- package/dist/fetch-xhr-shim.esm.js +3440 -2448
- package/dist/fetch-xhr-shim.esm.min.js +1 -1
- package/dist/fetch-xhr-shim.polyfill.iife.js +3740 -2760
- package/dist/fetch-xhr-shim.polyfill.iife.min.js +1 -1
- package/package.json +4 -1
- package/polyfill.js +3740 -2760
|
@@ -101,8 +101,12 @@ function state(target) {
|
|
|
101
101
|
return target.__Event__;
|
|
102
102
|
}
|
|
103
103
|
const timeStamp = (new Date()).getTime();
|
|
104
|
+
function getFuncName(func) {
|
|
105
|
+
// ES5
|
|
106
|
+
return "name" in func ? func.name : "unknown";
|
|
107
|
+
}
|
|
104
108
|
function createTrustedPropertyDescriptor() {
|
|
105
|
-
let name = createTrustedPropertyDescriptor
|
|
109
|
+
let name = getFuncName(createTrustedPropertyDescriptor);
|
|
106
110
|
let idx = name.length;
|
|
107
111
|
let isTrusted = "NO";
|
|
108
112
|
return {
|
|
@@ -116,7 +120,7 @@ function createTrustedPropertyDescriptor() {
|
|
|
116
120
|
}
|
|
117
121
|
function Event_setTrusted(event, isTrusted) {
|
|
118
122
|
let s = state(event) || {};
|
|
119
|
-
s.isTrusted = `${createTrustedPropertyDescriptor
|
|
123
|
+
s.isTrusted = `${getFuncName(createTrustedPropertyDescriptor)}:${isTrusted ? "YES" : "NO"}`;
|
|
120
124
|
}
|
|
121
125
|
const EventE = (typeof Event !== "undefined" && Event) || EventP;
|
|
122
126
|
|
package/dist/cjs/fixes.js
CHANGED
|
@@ -145,8 +145,8 @@ function fixFetch(fetchFunc) {
|
|
|
145
145
|
}).bind(this))
|
|
146
146
|
.catch(function (e) {
|
|
147
147
|
reject(new TypeError("Failed to fetch"));
|
|
148
|
-
console.error(e);
|
|
149
148
|
processing = false;
|
|
149
|
+
console.error(e);
|
|
150
150
|
})
|
|
151
151
|
.then(function () { if (removeFn) {
|
|
152
152
|
removeFn();
|
|
@@ -202,8 +202,8 @@ function fixXMLHttpRequest(XHRClass) {
|
|
|
202
202
|
payload.promise.then((function (r) {
|
|
203
203
|
if (!state(this).aborted) {
|
|
204
204
|
if (withCredentials !== this.withCredentials) {
|
|
205
|
-
console.warn("Illegal to set the 'withCredentials' property on 'XMLHttpRequest': The value may only be set if the object's state is UNSENT or OPENED.");
|
|
206
205
|
this.withCredentials = withCredentials;
|
|
206
|
+
console.warn("Illegal to set the 'withCredentials' property on 'XMLHttpRequest': The value may only be set if the object's state is UNSENT or OPENED.");
|
|
207
207
|
}
|
|
208
208
|
_send.call(this, r !== "" ? r : undefined);
|
|
209
209
|
}
|
|
@@ -211,9 +211,9 @@ function fixXMLHttpRequest(XHRClass) {
|
|
|
211
211
|
state(this).processing = false;
|
|
212
212
|
}).bind(this))
|
|
213
213
|
.catch((function (e) {
|
|
214
|
-
console.error(e);
|
|
215
214
|
state(this).aborted = false;
|
|
216
215
|
state(this).processing = false;
|
|
216
|
+
console.error(e);
|
|
217
217
|
}).bind(this));
|
|
218
218
|
}
|
|
219
219
|
else {
|
package/dist/cjs/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const _Symbol = {
|
|
4
|
-
iterator: ((typeof Symbol === "function"
|
|
5
|
-
toStringTag: ((typeof Symbol === "function"
|
|
4
|
+
iterator: ((typeof Symbol === "function" && Symbol.iterator) || "Symbol(Symbol.iterator)"),
|
|
5
|
+
toStringTag: ((typeof Symbol === "function" && Symbol.toStringTag) || "Symbol(Symbol.toStringTag)"),
|
|
6
6
|
};
|
|
7
7
|
class DOMExceptionP extends Error {
|
|
8
8
|
constructor(message, name) {
|
|
@@ -99,8 +99,12 @@ function state(target) {
|
|
|
99
99
|
return target.__Event__;
|
|
100
100
|
}
|
|
101
101
|
const timeStamp = (new Date()).getTime();
|
|
102
|
+
function getFuncName(func) {
|
|
103
|
+
// ES5
|
|
104
|
+
return "name" in func ? func.name : "unknown";
|
|
105
|
+
}
|
|
102
106
|
function createTrustedPropertyDescriptor() {
|
|
103
|
-
let name = createTrustedPropertyDescriptor
|
|
107
|
+
let name = getFuncName(createTrustedPropertyDescriptor);
|
|
104
108
|
let idx = name.length;
|
|
105
109
|
let isTrusted = "NO";
|
|
106
110
|
return {
|
|
@@ -114,7 +118,7 @@ function createTrustedPropertyDescriptor() {
|
|
|
114
118
|
}
|
|
115
119
|
function Event_setTrusted(event, isTrusted) {
|
|
116
120
|
let s = state(event) || {};
|
|
117
|
-
s.isTrusted = `${createTrustedPropertyDescriptor
|
|
121
|
+
s.isTrusted = `${getFuncName(createTrustedPropertyDescriptor)}:${isTrusted ? "YES" : "NO"}`;
|
|
118
122
|
}
|
|
119
123
|
const EventE = (typeof Event !== "undefined" && Event) || EventP;
|
|
120
124
|
|
package/dist/esm/fixes.js
CHANGED
|
@@ -143,8 +143,8 @@ function fixFetch(fetchFunc) {
|
|
|
143
143
|
}).bind(this))
|
|
144
144
|
.catch(function (e) {
|
|
145
145
|
reject(new TypeError("Failed to fetch"));
|
|
146
|
-
console.error(e);
|
|
147
146
|
processing = false;
|
|
147
|
+
console.error(e);
|
|
148
148
|
})
|
|
149
149
|
.then(function () { if (removeFn) {
|
|
150
150
|
removeFn();
|
|
@@ -200,8 +200,8 @@ function fixXMLHttpRequest(XHRClass) {
|
|
|
200
200
|
payload.promise.then((function (r) {
|
|
201
201
|
if (!state(this).aborted) {
|
|
202
202
|
if (withCredentials !== this.withCredentials) {
|
|
203
|
-
console.warn("Illegal to set the 'withCredentials' property on 'XMLHttpRequest': The value may only be set if the object's state is UNSENT or OPENED.");
|
|
204
203
|
this.withCredentials = withCredentials;
|
|
204
|
+
console.warn("Illegal to set the 'withCredentials' property on 'XMLHttpRequest': The value may only be set if the object's state is UNSENT or OPENED.");
|
|
205
205
|
}
|
|
206
206
|
_send.call(this, r !== "" ? r : undefined);
|
|
207
207
|
}
|
|
@@ -209,9 +209,9 @@ function fixXMLHttpRequest(XHRClass) {
|
|
|
209
209
|
state(this).processing = false;
|
|
210
210
|
}).bind(this))
|
|
211
211
|
.catch((function (e) {
|
|
212
|
-
console.error(e);
|
|
213
212
|
state(this).aborted = false;
|
|
214
213
|
state(this).processing = false;
|
|
214
|
+
console.error(e);
|
|
215
215
|
}).bind(this));
|
|
216
216
|
}
|
|
217
217
|
else {
|
package/dist/esm/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const _Symbol = {
|
|
2
|
-
iterator: ((typeof Symbol === "function"
|
|
3
|
-
toStringTag: ((typeof Symbol === "function"
|
|
2
|
+
iterator: ((typeof Symbol === "function" && Symbol.iterator) || "Symbol(Symbol.iterator)"),
|
|
3
|
+
toStringTag: ((typeof Symbol === "function" && Symbol.toStringTag) || "Symbol(Symbol.toStringTag)"),
|
|
4
4
|
};
|
|
5
5
|
class DOMExceptionP extends Error {
|
|
6
6
|
constructor(message, name) {
|