]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/html/static/storage.js
Rollup merge of #85174 - GuillaumeGomez:doc-code-block-border-radius, r=jsha
[rust.git] / src / librustdoc / html / static / storage.js
index c68128516d252df82d1f873452bd17c8ca8e62c6..208afd2e732dd7366a577bda9321f9adab1e8050 100644 (file)
@@ -1,6 +1,5 @@
 // From rust:
 /* global resourcesSuffix */
-
 var darkThemes = ["dark", "ayu"];
 window.currentTheme = document.getElementById("themeStyle");
 window.mainTheme = document.getElementById("mainThemeStyle");
@@ -60,15 +59,15 @@ function onEach(arr, func, reversed) {
     if (arr && arr.length > 0 && func) {
         var length = arr.length;
         var i;
-        if (reversed !== true) {
-            for (i = 0; i < length; ++i) {
-                if (func(arr[i]) === true) {
+        if (reversed) {
+            for (i = length - 1; i >= 0; --i) {
+                if (func(arr[i])) {
                     return true;
                 }
             }
         } else {
-            for (i = length - 1; i >= 0; --i) {
-                if (func(arr[i]) === true) {
+            for (i = 0; i < length; ++i) {
+                if (func(arr[i])) {
                     return true;
                 }
             }
@@ -112,7 +111,7 @@ function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) {
 
     // If this new value comes from a system setting or from the previously
     // saved theme, no need to save it.
-    if (saveTheme === true) {
+    if (saveTheme) {
         updateLocalStorage("rustdoc-theme", newTheme);
     }
 
@@ -132,7 +131,7 @@ function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) {
             return true;
         }
     });
-    if (found === true) {
+    if (found) {
         styleElem.href = newHref;
     }
 }