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

Automatically expand section if url id point to one of its component #53094

Merged
merged 1 commit into from
Aug 9, 2018
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: 19 additions & 0 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2208,6 +2208,25 @@
};

autoCollapse(getPageId(), getCurrentValue("rustdoc-collapse") === "true");

if (window.location.hash && window.location.hash.length > 0) {
var hash = getPageId();
if (hash !== null) {
var elem = document.getElementById(hash);
if (elem && elem.offsetParent === null) {
console.log(elem, elem.parentNode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should perhaps have been removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oups indeed!

if (elem.parentNode && elem.parentNode.previousSibling) {
var collapses = elem.parentNode
.previousSibling
.getElementsByClassName("collapse-toggle");
if (collapses.length > 0) {
// The element is not visible, we need to make it appear!
collapseDocs(collapses[0], "show");
}
}
}
}
}
}());

// Sets the focus on the search bar at the top of the page
Expand Down