about summary refs log tree commit diff
path: root/src/librustdoc/html/static/js/main.js
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2024-04-16 23:55:32 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2024-04-17 16:49:11 +0200
commitec754cf2012d1aecf7fca8fa66c846d79e7b94a4 (patch)
tree817e27a54f054f319e31eff61f1c8ec82e8876fe /src/librustdoc/html/static/js/main.js
parentad18fe08de03fbb459c05475bddee22707b4f0ec (diff)
downloadrust-ec754cf2012d1aecf7fca8fa66c846d79e7b94a4.tar.gz
rust-ec754cf2012d1aecf7fca8fa66c846d79e7b94a4.zip
Fix copy-path button
Diffstat (limited to 'src/librustdoc/html/static/js/main.js')
-rw-r--r--src/librustdoc/html/static/js/main.js20
1 files changed, 2 insertions, 18 deletions
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js
index 940b62be0c9..2c114b1cf55 100644
--- a/src/librustdoc/html/static/js/main.js
+++ b/src/librustdoc/html/static/js/main.js
@@ -1797,31 +1797,15 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
         document.execCommand("copy");
         document.body.removeChild(el);
 
-        // There is always one children, but multiple childNodes.
-        but.children[0].style.display = "none";
-
-        let tmp;
-        if (but.childNodes.length < 2) {
-            tmp = document.createTextNode("✓");
-            but.appendChild(tmp);
-        } else {
-            onEachLazy(but.childNodes, e => {
-                if (e.nodeType === Node.TEXT_NODE) {
-                    tmp = e;
-                    return true;
-                }
-            });
-            tmp.textContent = "✓";
-        }
+        but.classList.add("clicked");
 
         if (reset_button_timeout !== null) {
             window.clearTimeout(reset_button_timeout);
         }
 
         function reset_button() {
-            tmp.textContent = "";
             reset_button_timeout = null;
-            but.children[0].style.display = "";
+            but.classList.remove("clicked");
         }
 
         reset_button_timeout = window.setTimeout(reset_button, 1000);