Rollup merge of #140868 - SpecificProtagonist:rustdoc-trait-impl-code-link, r=notriddle

rustdoc: Fix links with inline code in trait impl docs

Fixes #140857
This commit is contained in:
Matthias Krüger 2025-05-22 07:19:01 +02:00 committed by GitHub
commit 981bbf4197
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 1 deletions

View file

@ -1179,8 +1179,10 @@ function preLoadCss(cssUrl) {
onEachLazy(document.querySelectorAll(".toggle > summary:not(.hideme)"), el => {
// @ts-expect-error
// Clicking on the summary's contents should not collapse it,
// but links within should still fire.
el.addEventListener("click", e => {
if (e.target.tagName !== "SUMMARY" && e.target.tagName !== "A") {
if (!e.target.matches("summary, a, a *")) {
e.preventDefault();
}
});