]> git.lizzy.rs Git - rust.git/commitdiff
rustdoc: remove inline javascript from copy-path button
authorMichael Howell <michael@notriddle.com>
Fri, 27 Jan 2023 21:23:28 +0000 (14:23 -0700)
committerMichael Howell <michael@notriddle.com>
Fri, 27 Jan 2023 23:22:59 +0000 (16:22 -0700)
src/librustdoc/html/static/js/main.js
src/librustdoc/html/templates/print_item.html

index 604ab147f6a16ea5a251d6ed4a71aa59f295f9ac..b9ad8ef70e917af855f4857ed46fbc40c5056194 100644 (file)
@@ -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 = [];
 
index ee2880bf6d195e23a91bedf640a667c29052cbc3..3a1867b7feba3eda5980b0b3d8235fe59c8ab234 100644 (file)
@@ -6,7 +6,7 @@
         <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"> {#- -#}