Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,14 @@ function hideThemeButtonState() {
}
});

onEachLazy(document.querySelectorAll(".rustdoc-toggle > summary:not(.hideme)"), function(el) {
el.addEventListener("click", function(e) {
if (e.target.tagName != "SUMMARY") {
e.preventDefault();
}
});
});

onEachLazy(document.getElementsByClassName("notable-traits"), function(e) {
e.onclick = function() {
this.getElementsByClassName('notable-traits-tooltiptext')[0]
Expand Down
2 changes: 2 additions & 0 deletions src/test/rustdoc-gui/src/lib2/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub struct Foo {
}

impl Foo {
/// Some documentation
/// # A Heading
pub fn a_method(&self) {}
}

Expand Down
8 changes: 8 additions & 0 deletions src/test/rustdoc-gui/toggle-click-deadspace.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This test ensures that clicking on a method summary, but not on the "[-]",
// doesn't toggle the <details>.
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
assert-attribute: (".impl-items .rustdoc-toggle", {"open": ""})
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": ""})