From 4112b32080b3bc7e6d789b931fd5a8261836a113 Mon Sep 17 00:00:00 2001 From: Gert Hengeveld Date: Tue, 1 Dec 2020 11:23:31 +0100 Subject: [PATCH] Fix IE11 compatibility by avoiding ES6 syntax and using XHR instead of fetch. --- .../server/templates/base-manager-head.html | 21 +++++++++++++------ .../server/templates/base-preview-head.html | 21 +++++++++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/lib/core/src/server/templates/base-manager-head.html b/lib/core/src/server/templates/base-manager-head.html index 5686218e223..67893d600b4 100644 --- a/lib/core/src/server/templates/base-manager-head.html +++ b/lib/core/src/server/templates/base-manager-head.html @@ -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 */ + }) + ); }; diff --git a/lib/core/src/server/templates/base-preview-head.html b/lib/core/src/server/templates/base-preview-head.html index f80158c8098..3858e9c7f48 100644 --- a/lib/core/src/server/templates/base-preview-head.html +++ b/lib/core/src/server/templates/base-preview-head.html @@ -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 */ + }) + ); };