fix(polyfill): remove usage of backticks / template so it works with ie11

This commit is contained in:
Martin 2022-07-18 13:54:48 +02:00 committed by mfo
parent aab203aaae
commit 8a439be506
2 changed files with 91 additions and 4 deletions

View file

@ -1,5 +1,5 @@
diff --git a/node_modules/event-target-polyfill/index.js b/node_modules/event-target-polyfill/index.js
index 82f7f42..c7b65b7 100644
index 82f7f42..d198834 100644
--- a/node_modules/event-target-polyfill/index.js
+++ b/node_modules/event-target-polyfill/index.js
@@ -12,19 +12,6 @@ function isConstructor(fn) {
@ -27,7 +27,7 @@ index 82f7f42..c7b65b7 100644
if (arguments.length < 2) {
throw new TypeError(
- `TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only ${arguments.length} present.`
+ "TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, " \
+ "TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, " +
+ "but only " + arguments.length.toString() + "present."
);
}
@ -37,12 +37,12 @@ index 82f7f42..c7b65b7 100644
if (arguments.length < 2) {
throw new TypeError(
- `TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only ${arguments.length} present.`
+ "TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, " \
+ "TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, " +
+ "but only " + arguments.length.toString() + "present."
);
}
const __listeners = this.__listeners;
@@ -78,7 +67,7 @@ if (typeof root.EventTarget === "undefined" || !isConstructor(root.Event)) {
@@ -78,14 +67,14 @@ if (typeof root.EventTarget === "undefined" || !isConstructor(root.Event)) {
EventTarget.prototype.dispatchEvent = function (event) {
if (!(event instanceof Event)) {
throw new TypeError(
@ -51,3 +51,29 @@ index 82f7f42..c7b65b7 100644
);
}
const type = event.type;
const __listeners = this.__listeners;
const listenersForType = __listeners.get(type);
if (listenersForType) {
- for (const [listener, options] of listenersForType.entries()) {
+ listenersForType.forEach(function(options, listener) {
try {
if (typeof listener === "function") {
// Listener functions must be executed with the EventTarget as the `this` context.
@@ -100,7 +89,7 @@ if (typeof root.EventTarget === "undefined" || !isConstructor(root.Event)) {
// Unfortunately, this is the best we can do, which isn't great, because the
// native EventTarget will actually do this synchronously before moving to the next
// event in the loop.
- setTimeout(() => {
+ setTimeout(function() {
throw err;
});
}
@@ -109,7 +98,7 @@ if (typeof root.EventTarget === "undefined" || !isConstructor(root.Event)) {
// to remove it now.
listenersForType.delete(listener);
}
- }
+ })
}
// Since there are no cancellable events on a base EventTarget,
// this should always return true.

View file

@ -0,0 +1,61 @@
diff --git a/node_modules/formdata-polyfill/FormData.js b/node_modules/formdata-polyfill/FormData.js
index 8e73660..7b64ba4 100644
--- a/node_modules/formdata-polyfill/FormData.js
+++ b/node_modules/formdata-polyfill/FormData.js
@@ -71,7 +71,7 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData
function ensureArgs (args, expected) {
if (args.length < expected) {
- throw new TypeError(`${expected} argument required, but only ${args.length} present.`)
+ throw new TypeError(expected + " argument required, but only " + args.length.toString() + " present.")
}
}
@@ -342,11 +342,11 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData
['_blob'] () {
const boundary = '----formdata-polyfill-' + Math.random(),
chunks = [],
- p = `--${boundary}\r\nContent-Disposition: form-data; name="`
+ p = "--" + boundary +" \r\nContent-Disposition: form-data; name=\""
this.forEach((value, name) => typeof value == 'string'
- ? chunks.push(p + escape(normalizeLinefeeds(name)) + `"\r\n\r\n${normalizeLinefeeds(value)}\r\n`)
- : chunks.push(p + escape(normalizeLinefeeds(name)) + `"; filename="${escape(value.name)}"\r\nContent-Type: ${value.type||"application/octet-stream"}\r\n\r\n`, value, `\r\n`))
- chunks.push(`--${boundary}--`)
+ ? chunks.push(p + escape(normalizeLinefeeds(name)) + "\"\r\n\r\n" + normalizeLinefeeds(value) + "\r\n")
+ : chunks.push(p + escape(normalizeLinefeeds(name)) + "\"; filename=\"" + escape(value.name) + "\r\nContent-Type: " + (value.type||"application/octet-stream") + "\r\n\r\n", value, "\r\n"))
+ chunks.push("--"+boundary+"--")
return new Blob(chunks, {
type: "multipart/form-data; boundary=" + boundary
})
diff --git a/node_modules/formdata-polyfill/formdata-to-blob.js b/node_modules/formdata-polyfill/formdata-to-blob.js
index 5a0a517..0b7fbd7 100644
--- a/node_modules/formdata-polyfill/formdata-to-blob.js
+++ b/node_modules/formdata-polyfill/formdata-to-blob.js
@@ -16,22 +16,22 @@ const escape = (str, filename) =>
export function formDataToBlob (formData, BlobClass = Blob) {
const boundary = ('----formdata-polyfill-' + Math.random())
const chunks = []
- const prefix = `--${boundary}\r\nContent-Disposition: form-data; name="`
+ const prefix = "--"+$boundary+"\r\nContent-Disposition: form-data; name=\""
for (let [name, value] of formData) {
if (typeof value === 'string') {
- chunks.push(prefix + escape(name) + `"\r\n\r\n${value.replace(/\r(?!\n)|(?<!\r)\n/g, '\r\n')}\r\n`)
+ chunks.push(prefix + escape(name) + "\"\r\n\r\n" + value.replace(/\r(?!\n)|(?<!\r)\n/g, '\r\n') + "\r\n")
} else {
chunks.push(
- prefix + escape(name) + `"; filename="${escape(value.name, 1)}"\r\n` +
- `Content-Type: ${value.type || 'application/octet-stream'}\r\n\r\n`,
+ prefix + escape(name) + "\"; filename=\"" + escape(value.name, 1) + "\r\n" +
+ "Content-Type: " + (value.type || 'application/octet-stream') + "\r\n\r\n",
value,
'\r\n'
)
}
}
- chunks.push(`--${boundary}--`)
+ chunks.push("--" + boundary + "--")
return new BlobClass(chunks, {
type: 'multipart/form-data; boundary=' + boundary