Skip to content

Commit

Permalink
Auto merge of #91188 - jsha:fix-click-items, r=Manishearth
Browse files Browse the repository at this point in the history
Fix clicking on anchors inside summary tags

Fixes #91184

r? `@camelid`
  • Loading branch information
bors committed Nov 24, 2021
2 parents 8a48b37 + 04cb0dc commit b426445
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ function hideThemeButtonState() {

onEachLazy(document.querySelectorAll(".rustdoc-toggle > summary:not(.hideme)"), function(el) {
el.addEventListener("click", function(e) {
if (e.target.tagName != "SUMMARY") {
if (e.target.tagName != "SUMMARY" && e.target.tagName != "A") {
e.preventDefault();
}
});
Expand Down
4 changes: 4 additions & 0 deletions src/test/rustdoc-gui/toggle-click-deadspace.goml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ click: "h4.code-header" // This is the position of "pub" in "pub fn a_method"
assert-attribute: (".impl-items .rustdoc-toggle", {"open": ""})
click: ".impl-items .rustdoc-toggle summary::before" // This is the position of "[-]" next to that pub fn.
assert-attribute-false: (".impl-items .rustdoc-toggle", {"open": ""})

// Click the "Trait" part of "impl Trait" and verify it navigates.
click: "#impl-Trait h3 a:first-of-type"
assert-text: (".fqn .in-band", "Trait lib2::Trait")

0 comments on commit b426445

Please sign in to comment.