Skip to content

Commit

Permalink
Rollup merge of rust-lang#53094 - GuillaumeGomez:automatic-expand, r=nrc
Browse files Browse the repository at this point in the history
Automatically expand section if url id point to one of its component

Fixes rust-lang#52517.

r? @nrc
  • Loading branch information
cramertj authored Aug 8, 2018
2 parents 88c74ef + c70eb4b commit 556995e
Showing 1 changed file with 19 additions and 0 deletions.
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);
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

0 comments on commit 556995e

Please sign in to comment.