From 62cefa412944b96b8ba14f93f6faee6ebd2b61b9 Mon Sep 17 00:00:00 2001 From: Adam Daniels Date: Tue, 28 Jul 2026 14:59:40 -0400 Subject: [PATCH] Fix duplicate View source links after client-side navigation createSourceLinks() inserts a [ View source ] toggle before every .source_code table with no check for whether one is already there. The default template's instant-navigation code (introduced in 0.9.38) calls window.__app() again each time it swaps #main's content, re-running createSourceLinks() on top of markup that can still hold a previous toggle, so every source block ends up with two. Skip a source_code table that already has a showSource sibling. --- CHANGELOG.md | 2 ++ templates/default/fulldoc/html/js/app.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c708cf607..6be394b3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # main +- Fix duplicate "View source" links after client-side navigation in default HTML template + # [0.9.45] - July 14th, 2026 [0.9.45]: https://github.com/lsegal/yard/compare/v0.9.44...v0.9.45 diff --git a/templates/default/fulldoc/html/js/app.js b/templates/default/fulldoc/html/js/app.js index f84a8c188..a5c877ab5 100644 --- a/templates/default/fulldoc/html/js/app.js +++ b/templates/default/fulldoc/html/js/app.js @@ -144,6 +144,9 @@ function createSourceLinks() { queryAll(".method_details_list .source_code").forEach((sourceCode) => { + if (sourceCode.previousElementSibling?.classList.contains("showSource")) + return; + const toggleWrapper = document.createElement("span"); const link = document.createElement("a");