Skip to content

Commit

Permalink
ui: polyfill for Object.entries
Browse files Browse the repository at this point in the history
  • Loading branch information
unbyte committed Oct 22, 2020
1 parent 0f146cd commit 5dfd61a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ui/gulpfile.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }))
})
17 changes: 17 additions & 0 deletions ui/public/checkBrowser.js → ui/public/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
2 changes: 1 addition & 1 deletion ui/public/diagnoseReport.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script src="%PUBLIC_URL%/checkBrowser.js"></script>
<script src="%PUBLIC_URL%/compat.js"></script>
<div id="root"></div>
</body>
</html>
2 changes: 1 addition & 1 deletion ui/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script src="%PUBLIC_URL%/checkBrowser.js"></script>
<script src="%PUBLIC_URL%/compat.js"></script>
<div id="dashboard_page_spinner"><div class="dot-flashing"></div></div>
<div id="root"></div>
</body>
Expand Down

0 comments on commit 5dfd61a

Please sign in to comment.