about summary refs log tree commit diff
diff options
context:
space:
mode:
authornasso <nassomails@gmail.com>2020-10-23 18:58:42 +0200
committernasso <nassomails@gmail.com>2020-10-23 18:58:42 +0200
commita0ce1e095e0d89d35ff3de20541dd4faf79607da (patch)
treeefa20812b7d9302b063d5759fed4a3f3276574b8
parent07a63e6d1fabf3560e8e1e17c1d56b10a06152d9 (diff)
downloadrust-a0ce1e095e0d89d35ff3de20541dd4faf79607da.tar.gz
rust-a0ce1e095e0d89d35ff3de20541dd4faf79607da.zip
Always store Rustdoc theme when it's changed
-rw-r--r--src/librustdoc/html/static/storage.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/librustdoc/html/static/storage.js b/src/librustdoc/html/static/storage.js
index a027d6845ea..ef734f260af 100644
--- a/src/librustdoc/html/static/storage.js
+++ b/src/librustdoc/html/static/storage.js
@@ -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;
     }
@@ -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);
-        }
     }
 }