Merge pull request #13295 from minaminao/fix-dark-mode-bug

Fix dark mode bug
This commit is contained in:
chriseth 2022-07-25 21:03:03 +02:00 committed by GitHub
commit dd9a57b1fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,15 +4,16 @@ document.addEventListener('DOMContentLoaded', function() {
var mode = (isDay ? "Day" : "Night");
localStorage.setItem("css-mode", mode);
var daysheet = $('link[href="_static/pygments.css"]')[0].sheet;
var url_root = DOCUMENTATION_OPTIONS.URL_ROOT == "./" ? "" : DOCUMENTATION_OPTIONS.URL_ROOT;
var daysheet = $(`link[href="${url_root}_static/pygments.css"]`)[0].sheet;
daysheet.disabled = !isDay;
var nightsheet = $('link[href="_static/css/dark.css"]')[0];
var nightsheet = $(`link[href="${url_root}_static/css/dark.css"]`)[0];
if (!isDay && nightsheet === undefined) {
var element = document.createElement("link");
element.setAttribute("rel", "stylesheet");
element.setAttribute("type", "text/css");
element.setAttribute("href", "_static/css/dark.css");
element.setAttribute("href", `${url_root}_static/css/dark.css`);
document.getElementsByTagName("head")[0].appendChild(element);
return;
}