Skip to content

Commit

Permalink
Unrolled build for rust-lang#115931
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#115931 - GuillaumeGomez:remove-empty-h2, r=notriddle

Move mobile topbar title creation entirely into JS

I was looking at potential size improvements and saw that we had an empty `h2` tag for the mobile topbar title that was filled with JS. So at this point, I think it's fine to just completely generate it from JS, like that the w3c HTML validator will emit one less warning.

r? `@notriddle`
  • Loading branch information
rust-timer committed Sep 19, 2023
2 parents 65ea825 + 354397f commit 520305f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ window.currentCrate = getVar("current-crate");
function setMobileTopbar() {
// FIXME: It would be nicer to generate this text content directly in HTML,
// but with the current code it's hard to get the right information in the right place.
const mobileLocationTitle = document.querySelector(".mobile-topbar h2");
const mobileTopbar = document.querySelector(".mobile-topbar");
const locationTitle = document.querySelector(".sidebar h2.location");
if (mobileLocationTitle && locationTitle) {
mobileLocationTitle.innerHTML = locationTitle.innerHTML;
if (mobileTopbar && locationTitle) {
const mobileTitle = document.createElement("h2");
mobileTitle.innerHTML = locationTitle.innerHTML;
mobileTopbar.appendChild(mobileTitle);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/html/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@
<img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {# #}
{% endif %}
</a> {# #}
<h2></h2> {# #}
</nav> {# #}
</nav>
{% endif %}
<nav class="sidebar"> {# #}
{% if page.css_class != "src" %}
Expand Down

0 comments on commit 520305f

Please sign in to comment.