Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: remove experimental API in checkBrowser.js #776

Merged
merged 4 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }))
})
19 changes: 18 additions & 1 deletion ui/public/checkBrowser.js → ui/public/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,25 @@ function checkBrowser() {
d.getElementsByTagName('a')[0].onclick = function () {
d.getElementsByTagName('div')[0].style.top = '-60px'
}
document.body.prepend(d)
document.body.insertBefore(d, document.body.firstChild)
}
}

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