diff options
| author | kennytm <kennytm@gmail.com> | 2018-08-09 16:58:41 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-09 16:58:41 +0800 |
| commit | dad5b6c554b034a5a366067a8aef31cef3772a61 (patch) | |
| tree | a46cb4f2464d5080957ad36fd510bf533f5ad59c /src/librustdoc/html | |
| parent | c6f55bca7f19d9325e46678d47178447ad02732e (diff) | |
| parent | c70eb4b6eaeb0256422d32bed949b15ecc37bac9 (diff) | |
| download | rust-dad5b6c554b034a5a366067a8aef31cef3772a61.tar.gz rust-dad5b6c554b034a5a366067a8aef31cef3772a61.zip | |
Rollup merge of #53094 - GuillaumeGomez:automatic-expand, r=nrc
Automatically expand section if url id point to one of its component Fixes #52517. r? @nrc
Diffstat (limited to 'src/librustdoc/html')
| -rw-r--r-- | src/librustdoc/html/static/main.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 62ef5626ee5..07507047dc2 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -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 |
