Skip to content

Commit 556995e

Browse files
authored
Rollup merge of rust-lang#53094 - GuillaumeGomez:automatic-expand, r=nrc
Automatically expand section if url id point to one of its component Fixes rust-lang#52517. r? @nrc
2 parents 88c74ef + c70eb4b commit 556995e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/librustdoc/html/static/main.js

+19
Original file line numberDiff line numberDiff line change
@@ -2208,6 +2208,25 @@
22082208
};
22092209

22102210
autoCollapse(getPageId(), getCurrentValue("rustdoc-collapse") === "true");
2211+
2212+
if (window.location.hash && window.location.hash.length > 0) {
2213+
var hash = getPageId();
2214+
if (hash !== null) {
2215+
var elem = document.getElementById(hash);
2216+
if (elem && elem.offsetParent === null) {
2217+
console.log(elem, elem.parentNode);
2218+
if (elem.parentNode && elem.parentNode.previousSibling) {
2219+
var collapses = elem.parentNode
2220+
.previousSibling
2221+
.getElementsByClassName("collapse-toggle");
2222+
if (collapses.length > 0) {
2223+
// The element is not visible, we need to make it appear!
2224+
collapseDocs(collapses[0], "show");
2225+
}
2226+
}
2227+
}
2228+
}
2229+
}
22112230
}());
22122231

22132232
// Sets the focus on the search bar at the top of the page

0 commit comments

Comments
 (0)