Rollup merge of #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`
This commit is contained in:
Matthias Krüger 2023-09-19 01:29:43 +02:00 committed by GitHub
commit 575e091b5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -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);
}
}

View File

@ -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" %}