Skip to content

Commit

Permalink
Always store Rustdoc theme when it's changed
Browse files Browse the repository at this point in the history
  • Loading branch information
nasso committed Oct 23, 2020
1 parent 07a63e6 commit a0ce1e0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/librustdoc/html/static/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) {
var fullNewTheme = newTheme + resourcesSuffix + ".css";
var newHref = mainStyleElem.href.replace(fullBasicCss, fullNewTheme);

// If this new value comes from a system setting or from the previously
// saved theme, no need to save it.
if (saveTheme === true) {
updateLocalStorage("rustdoc-theme", newTheme);
}

if (styleElem.href === newHref) {
return;
}
Expand All @@ -112,11 +118,6 @@ function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) {
});
if (found === true) {
styleElem.href = newHref;
// If this new value comes from a system setting or from the previously
// saved theme, no need to save it.
if (saveTheme === true) {
updateLocalStorage("rustdoc-theme", newTheme);
}
}
}

Expand Down

0 comments on commit a0ce1e0

Please sign in to comment.