rustdoc: simplify link anchor to section expand JS
This commit is contained in:
parent
49143814e1
commit
5dfa6a8922
1 changed files with 5 additions and 7 deletions
|
@ -813,16 +813,14 @@ function loadCss(cssUrl) {
|
|||
hideSidebar();
|
||||
});
|
||||
|
||||
onEachLazy(document.getElementsByTagName("a"), el => {
|
||||
onEachLazy(document.querySelectorAll("a[href^='#']"), el => {
|
||||
// For clicks on internal links (<A> tags with a hash property), we expand the section we're
|
||||
// jumping to *before* jumping there. We can't do this in onHashChange, because it changes
|
||||
// the height of the document so we wind up scrolled to the wrong place.
|
||||
if (el.hash) {
|
||||
el.addEventListener("click", () => {
|
||||
expandSection(el.hash.slice(1));
|
||||
hideSidebar();
|
||||
});
|
||||
}
|
||||
el.addEventListener("click", () => {
|
||||
expandSection(el.hash.slice(1));
|
||||
hideSidebar();
|
||||
});
|
||||
});
|
||||
|
||||
onEachLazy(document.querySelectorAll(".rustdoc-toggle > summary:not(.hideme)"), el => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue