about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-11-13 10:11:19 +0000
committerbors <bors@rust-lang.org>2023-11-13 10:11:19 +0000
commit891c6eebe697a7da6e38214e6acebb883b557d4b (patch)
treefa335c38f6045afd2a05a74e85a257650ee09eab
parentc225c45bce099e4ff6c61c73a425326d1625ed2f (diff)
parent8b1bcc8d5ba65ecf6741436246ed27f74a71d40c (diff)
downloadrust-891c6eebe697a7da6e38214e6acebb883b557d4b.tar.gz
rust-891c6eebe697a7da6e38214e6acebb883b557d4b.zip
Auto merge of #117864 - notriddle:notriddle/rustdoc-root, r=GuillaumeGomez
rustdoc: use `.rustdoc` class instead of `body`

This didn't show up in our local tests, because the problem is actually caused by docs.rs rewritten HTML (which relocates the classes that this code looked for from the body tag to a child div).

Fixes #117290

r? `@GuillaumeGomez`

Both problems are regressions introduced by #115948
-rw-r--r--src/librustdoc/html/static/js/main.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js
index 7c052606aba..615fb08c76f 100644
--- a/src/librustdoc/html/static/js/main.js
+++ b/src/librustdoc/html/static/js/main.js
@@ -54,7 +54,7 @@ function setMobileTopbar() {
     if (mobileTopbar) {
         const mobileTitle = document.createElement("h2");
         mobileTitle.className = "location";
-        if (hasClass(document.body, "crate")) {
+        if (hasClass(document.querySelector(".rustdoc"), "crate")) {
             mobileTitle.innerText = `Crate ${window.currentCrate}`;
         } else if (locationTitle) {
             mobileTitle.innerHTML = locationTitle.innerHTML;
@@ -485,7 +485,7 @@ function preLoadCss(cssUrl) {
                 return;
             }
 
-            const modpath = hasClass(document.body, "mod") ? "../" : "";
+            const modpath = hasClass(document.querySelector(".rustdoc"), "mod") ? "../" : "";
 
             const h3 = document.createElement("h3");
             h3.innerHTML = `<a href="${modpath}index.html#${id}">${longty}</a>`;