mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Rollup merge of #106016 - notriddle:notriddle/link-has-onclick, r=GuillaumeGomez
rustdoc: simplify link anchor to section expand JS
This commit is contained in:
commit
793df7f5f0
@ -813,16 +813,14 @@ function loadCss(cssUrl) {
|
|||||||
hideSidebar();
|
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
|
// 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
|
// 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.
|
// the height of the document so we wind up scrolled to the wrong place.
|
||||||
if (el.hash) {
|
el.addEventListener("click", () => {
|
||||||
el.addEventListener("click", () => {
|
expandSection(el.hash.slice(1));
|
||||||
expandSection(el.hash.slice(1));
|
hideSidebar();
|
||||||
hideSidebar();
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onEachLazy(document.querySelectorAll(".rustdoc-toggle > summary:not(.hideme)"), el => {
|
onEachLazy(document.querySelectorAll(".rustdoc-toggle > summary:not(.hideme)"), el => {
|
||||||
|
Loading…
Reference in New Issue
Block a user