Skip to content

Commit 8b1bcc8

Browse files
committedNov 13, 2023
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 rust-lang#117290
1 parent ea1e5cc commit 8b1bcc8

File tree

1 file changed

+2
-2
lines changed
  • src/librustdoc/html/static/js

1 file changed

+2
-2
lines changed
 

‎src/librustdoc/html/static/js/main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function setMobileTopbar() {
5454
if (mobileTopbar) {
5555
const mobileTitle = document.createElement("h2");
5656
mobileTitle.className = "location";
57-
if (hasClass(document.body, "crate")) {
57+
if (hasClass(document.querySelector(".rustdoc"), "crate")) {
5858
mobileTitle.innerText = `Crate ${window.currentCrate}`;
5959
} else if (locationTitle) {
6060
mobileTitle.innerHTML = locationTitle.innerHTML;
@@ -485,7 +485,7 @@ function preLoadCss(cssUrl) {
485485
return;
486486
}
487487

488-
const modpath = hasClass(document.body, "mod") ? "../" : "";
488+
const modpath = hasClass(document.querySelector(".rustdoc"), "mod") ? "../" : "";
489489

490490
const h3 = document.createElement("h3");
491491
h3.innerHTML = `<a href="${modpath}index.html#${id}">${longty}</a>`;

0 commit comments

Comments
 (0)