Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc: remove redundant expandSection code from main.js #110162

Merged
merged 1 commit into from
Apr 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,6 @@ function preLoadCss(cssUrl) {
},
};

function getPageId() {
return window.location.hash.replace(/^#/, "");
}

const toggleAllDocsId = "toggle-all-docs";
let savedHash = "";

Expand All @@ -355,12 +351,12 @@ function preLoadCss(cssUrl) {
}
}
// This part is used in case an element is not visible.
if (savedHash !== window.location.hash) {
savedHash = window.location.hash;
if (savedHash.length === 0) {
return;
const pageId = window.location.hash.replace(/^#/, "");
if (savedHash !== pageId) {
savedHash = pageId;
if (pageId !== "") {
expandSection(pageId);
}
expandSection(savedHash.slice(1)); // we remove the '#'
}
}

Expand Down Expand Up @@ -699,11 +695,6 @@ function preLoadCss(cssUrl) {
}

});

const pageId = getPageId();
GuillaumeGomez marked this conversation as resolved.
Show resolved Hide resolved
if (pageId !== "") {
expandSection(pageId);
}
}());

window.rustdoc_add_line_numbers_to_examples = () => {
Expand Down