Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inhibit clicks on summary's children #91103

Merged
merged 2 commits into from
Nov 23, 2021
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": ""})