about summary refs log tree commit diff
path: root/src/librustdoc/html
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2018-08-05 18:22:44 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2018-08-05 19:44:10 +0200
commitc70eb4b6eaeb0256422d32bed949b15ecc37bac9 (patch)
tree10b7f6ba01f5bcf850e5ac84bd8293ef3723ca00 /src/librustdoc/html
parent579adf8c727861841b4819b4913385c2782977fb (diff)
downloadrust-c70eb4b6eaeb0256422d32bed949b15ecc37bac9.tar.gz
rust-c70eb4b6eaeb0256422d32bed949b15ecc37bac9.zip
Automatically expand section if url id point to one of its component
Diffstat (limited to 'src/librustdoc/html')
-rw-r--r--src/librustdoc/html/static/main.js19
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