1
Fork 0

Expand sub code blocks block content when hidden when the page hash refers to it

This commit is contained in:
Guillaume Gomez 2020-03-30 14:06:37 +02:00
parent 0fcb7dabac
commit fc61cca41c

View file

@ -306,6 +306,14 @@ function defocusSearchBar() {
function expandSection(id) {
var elem = document.getElementById(id);
if (elem && isHidden(elem)) {
if (elem.tagName === "CODE" && elem.parentNode.tagName === "H4") {
// We are in a trait implementation, what we want is the parent.
elem = elem.parentNode;
if (elem.id !== null && elem.id.length > 0) {
// Change the id to the parent which is "more clear" and better for users.
window.location.hash = elem.id;
}
}
var h3 = elem.parentNode.previousElementSibling;
if (h3 && h3.tagName !== "H3") {
h3 = h3.previousElementSibling; // skip div.docblock