about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-08-22 15:15:40 +0200
committerGitHub <noreply@github.com>2019-08-22 15:15:40 +0200
commit1f56441a00406ea5bd44ae43cdd639c1ffa2b101 (patch)
tree3da4f11c8378ee413b1d03135508121fff9a8639
parent30fd79cb6c8d68df10392595231a55e83f217f61 (diff)
parent3375b05cd03a60cd7e2df0e21e232c73ff8a01cb (diff)
Rollup merge of #63782 - GuillaumeGomez:theme-switch-fix, r=kinnison
Fix confusion in theme picker functions

To reproduce the bug currently: click on the theme picker button twice (to show it then hide it). Then click anywhere else: the dropdown menu appears again.

The problem was coming from a confusion of what the `hideThemeButtonState` and `showThemeButtonState` were supposed to do. I switched their codes and updated the `switchThemeButtonState` function. It now works as expected.

r? @kinnison
-rw-r--r--src/librustdoc/html/render.rs16
-rw-r--r--src/librustdoc/html/static/main.js12
2 files changed, 14 insertions, 14 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 211c4157da8..b64e74468e6 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -876,22 +876,22 @@ r#"var themes = document.getElementById("theme-choices");
 var themePicker = document.getElementById("theme-picker");
 
 function showThemeButtonState() {{
-    themes.style.display = "none";
-    themePicker.style.borderBottomRightRadius = "3px";
-    themePicker.style.borderBottomLeftRadius = "3px";
-}}
-
-function hideThemeButtonState() {{
     themes.style.display = "block";
     themePicker.style.borderBottomRightRadius = "0";
     themePicker.style.borderBottomLeftRadius = "0";
 }}
 
+function hideThemeButtonState() {{
+    themes.style.display = "none";
+    themePicker.style.borderBottomRightRadius = "3px";
+    themePicker.style.borderBottomLeftRadius = "3px";
+}}
+
 function switchThemeButtonState() {{
     if (themes.style.display === "block") {{
-        showThemeButtonState();
-    }} else {{
         hideThemeButtonState();
+    }} else {{
+        showThemeButtonState();
     }}
 }};
 
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 82d2c11b249..3d0f00095ac 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -105,9 +105,9 @@ if (!DOMTokenList.prototype.remove) {
                 sidebar.appendChild(div);
             }
         }
-        var themePicker = document.getElementsByClassName("theme-picker");
-        if (themePicker && themePicker.length > 0) {
-            themePicker[0].style.display = "none";
+        var themePickers = document.getElementsByClassName("theme-picker");
+        if (themePickers && themePickers.length > 0) {
+            themePickers[0].style.display = "none";
         }
     }
 
@@ -123,9 +123,9 @@ if (!DOMTokenList.prototype.remove) {
             filler.remove();
         }
         document.getElementsByTagName("body")[0].style.marginTop = "";
-        var themePicker = document.getElementsByClassName("theme-picker");
-        if (themePicker && themePicker.length > 0) {
-            themePicker[0].style.display = null;
+        var themePickers = document.getElementsByClassName("theme-picker");
+        if (themePickers && themePickers.length > 0) {
+            themePickers[0].style.display = null;
         }
     }