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

rustdoc: remove inline javascript from copy-path button #107391

Merged
merged 1 commit into from
Jan 28, 2023
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
6 changes: 5 additions & 1 deletion src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,11 @@ function loadCss(cssUrl) {
(function() {
let reset_button_timeout = null;

window.copy_path = but => {
const but = document.getElementById("copy-path");
if (!but) {
return;
}
but.onclick = () => {
const parent = but.parentElement;
const path = [];

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/templates/print_item.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h1> {#- -#}
<a href="{{component.path|safe}}index.html">{{component.name}}</a>::<wbr>
{%- endfor -%}
<a class="{{item_type}}" href="#">{{name}}</a> {#- -#}
<button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"> {#- -#}
<button id="copy-path" title="Copy item path to clipboard"> {#- -#}
<img src="{{static_root_path|safe}}{{clipboard_svg}}" {# -#}
width="19" height="18" {# -#}
alt="Copy item path"> {#- -#}
Expand Down