Skip to content

Commit a07fc3d

Browse files
Rollup merge of #78293 - nasso:master, r=GuillaumeGomez
Always store Rustdoc theme when it's changed `switchTheme` (too) lazily updated the value of `rustdoc-theme` in `localStorage`, leading to an incorrect stored value when the system theme is the same as the default (`light`) theme. Fixes #78273
2 parents 2362659 + a0ce1e0 commit a07fc3d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/librustdoc/html/static/storage.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) {
9494
var fullNewTheme = newTheme + resourcesSuffix + ".css";
9595
var newHref = mainStyleElem.href.replace(fullBasicCss, fullNewTheme);
9696

97+
// If this new value comes from a system setting or from the previously
98+
// saved theme, no need to save it.
99+
if (saveTheme === true) {
100+
updateLocalStorage("rustdoc-theme", newTheme);
101+
}
102+
97103
if (styleElem.href === newHref) {
98104
return;
99105
}
@@ -112,11 +118,6 @@ function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) {
112118
});
113119
if (found === true) {
114120
styleElem.href = newHref;
115-
// If this new value comes from a system setting or from the previously
116-
// saved theme, no need to save it.
117-
if (saveTheme === true) {
118-
updateLocalStorage("rustdoc-theme", newTheme);
119-
}
120121
}
121122
}
122123

0 commit comments

Comments
 (0)