Skip to content

Commit 7115404

Browse files
Open lint when clicking on its anchor
1 parent b33977b commit 7115404

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

util/gh-pages/index_template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ <h1>Clippy Lints</h1> {# #}
150150
<h2 class="panel-title"> {# #}
151151
<div class="panel-title-name" id="lint-{{lint.id}}"> {# #}
152152
<span>{{lint.id}}</span> {#+ #}
153-
<a href="#{{lint.id}}" class="anchor label label-default">&para;</a> {#+ #}
153+
<a href="#{{lint.id}}" onclick="lintAnchor(event)" class="anchor label label-default">&para;</a> {#+ #}
154154
<a href="" class="anchor label label-default" onclick="copyToClipboard(event)"> {# #}
155155
&#128203; {# #}
156156
</a> {# #}

util/gh-pages/script.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ function expandLint(lintId) {
151151
highlightIfNeeded(lintId);
152152
}
153153

154+
function lintAnchor(event) {
155+
event.preventDefault();
156+
event.stopPropagation();
157+
158+
const id = event.target.getAttribute("href").replace("#", "");
159+
window.location.hash = id;
160+
161+
expandLint(id);
162+
}
163+
154164
function copyToClipboard(event) {
155165
event.preventDefault();
156166
event.stopPropagation();

0 commit comments

Comments
 (0)