Fix IE11 compatibility by avoiding ES6 syntax and using XHR instead of fetch.

This commit is contained in:
Gert Hengeveld 2020-12-01 11:23:31 +01:00
parent 0e56733636
commit 4112b32080
2 changed files with 30 additions and 12 deletions

View File

@ -27,11 +27,20 @@
window.onerror = function onerror(message, source, line, column, err) {
if (window.CONFIG_TYPE !== 'DEVELOPMENT') return;
// eslint-disable-next-line no-var, vars-on-top
var error = { message: err.message, name: err.name, stack: err.stack };
window.fetch('/runtime-error', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message, source, line, column, error, origin: 'manager' }),
});
var xhr = new window.XMLHttpRequest();
xhr.open('POST', '/runtime-error');
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
xhr.send(
JSON.stringify({
/* eslint-disable object-shorthand */
message: message,
source: source,
line: line,
column: column,
error: { message: err.message, name: err.name, stack: err.stack },
origin: 'manager',
/* eslint-enable object-shorthand */
})
);
};
</script>

View File

@ -115,11 +115,20 @@
window.onerror = function onerror(message, source, line, column, err) {
if (window.CONFIG_TYPE !== 'DEVELOPMENT') return;
// eslint-disable-next-line no-var, vars-on-top
var error = { message: err.message, name: err.name, stack: err.stack };
window.fetch('/runtime-error', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message, source, line, column, error, origin: 'preview' }),
});
var xhr = new window.XMLHttpRequest();
xhr.open('POST', '/runtime-error');
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
xhr.send(
JSON.stringify({
/* eslint-disable object-shorthand */
message: message,
source: source,
line: line,
column: column,
error: { message: err.message, name: err.name, stack: err.stack },
origin: 'preview',
/* eslint-enable object-shorthand */
})
);
};
</script>