From 8e3e926eaddb620b59b2be2fa780aae0ccde50cb Mon Sep 17 00:00:00 2001 From: Helios Date: Thu, 22 Oct 2020 11:44:15 +0800 Subject: [PATCH 1/3] ui: remove experimental API in checkBrowser.js --- ui/public/checkBrowser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/public/checkBrowser.js b/ui/public/checkBrowser.js index 786e2c6604..2606379cf9 100644 --- a/ui/public/checkBrowser.js +++ b/ui/public/checkBrowser.js @@ -40,7 +40,7 @@ function checkBrowser() { d.getElementsByTagName('a')[0].onclick = function () { d.getElementsByTagName('div')[0].style.top = '-60px' } - document.body.prepend(d) + document.body.prepend ? document.body.prepend(d) : document.body.insertBefore(d, document.body.firstChild) } } From 0f146cdb62e814f2fc4b1323b9b611005b3f58b6 Mon Sep 17 00:00:00 2001 From: Helios Date: Thu, 22 Oct 2020 18:58:14 +0800 Subject: [PATCH 2/3] ui: remove experimental API in checkBrowser.js --- ui/public/checkBrowser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/public/checkBrowser.js b/ui/public/checkBrowser.js index 2606379cf9..12032d2fb3 100644 --- a/ui/public/checkBrowser.js +++ b/ui/public/checkBrowser.js @@ -40,7 +40,7 @@ function checkBrowser() { d.getElementsByTagName('a')[0].onclick = function () { d.getElementsByTagName('div')[0].style.top = '-60px' } - document.body.prepend ? document.body.prepend(d) : document.body.insertBefore(d, document.body.firstChild) + document.body.insertBefore(d, document.body.firstChild) } } From 5dfd61a76ec07af9a1a151808e1c7b34a5064a69 Mon Sep 17 00:00:00 2001 From: Helios Date: Thu, 22 Oct 2020 19:32:57 +0800 Subject: [PATCH 3/3] ui: polyfill for Object.entries --- ui/gulpfile.esm.js | 2 +- ui/public/{checkBrowser.js => compat.js} | 17 +++++++++++++++++ ui/public/diagnoseReport.html | 2 +- ui/public/index.html | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) rename ui/public/{checkBrowser.js => compat.js} (84%) diff --git a/ui/gulpfile.esm.js b/ui/gulpfile.esm.js index 8b0b3ab89d..6af6beb95c 100644 --- a/ui/gulpfile.esm.js +++ b/ui/gulpfile.esm.js @@ -59,7 +59,7 @@ function updateBrowserList() { } task('gen:browserlist', () => { - return src('public/checkBrowser.js') + return src('public/compat.js') .pipe(updateBrowserList()) .pipe(dest('public', { overwrite: true })) }) diff --git a/ui/public/checkBrowser.js b/ui/public/compat.js similarity index 84% rename from ui/public/checkBrowser.js rename to ui/public/compat.js index 12032d2fb3..ba54664c7a 100644 --- a/ui/public/checkBrowser.js +++ b/ui/public/compat.js @@ -45,3 +45,20 @@ function checkBrowser() { } checkBrowser() + +// Dealing with compatibility issues manually for special cases + +// Object.entries +// see https://github.com/pingcap-incubator/tidb-dashboard/issues/770 +// polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries +if (!Object.entries) { + Object.entries = function( obj ){ + var ownProps = Object.keys( obj ), + i = ownProps.length, + resArray = new Array(i); // preallocate the Array + while (i--) + resArray[i] = [ownProps[i], obj[ownProps[i]]]; + + return resArray; + }; +} diff --git a/ui/public/diagnoseReport.html b/ui/public/diagnoseReport.html index 6114d4ae8a..aed243ffda 100644 --- a/ui/public/diagnoseReport.html +++ b/ui/public/diagnoseReport.html @@ -10,7 +10,7 @@ - +
diff --git a/ui/public/index.html b/ui/public/index.html index 08a29e991d..750c0f265c 100644 --- a/ui/public/index.html +++ b/ui/public/index.html @@ -91,7 +91,7 @@ - +