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-08-30 18:27:11 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2024-08-31 00:12:16 +0200
commit0d156f223a3fb389f813d8fdb0b588f95b3868aa (patch)
treee38d8e0cefb9f8c09dc4faf34a4e808904f88fc7 /src/librustdoc/html/static/js/main.js
parent0d634185dfddefe09047881175f35c65d68dcff1 (diff)
downloadrust-0d156f223a3fb389f813d8fdb0b588f95b3868aa.tar.gz
rust-0d156f223a3fb389f813d8fdb0b588f95b3868aa.zip
Unify scraped examples with other code examples
Diffstat (limited to 'src/librustdoc/html/static/js/main.js')
-rw-r--r--src/librustdoc/html/static/js/main.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js
index 75f2a1418cd..848ffc28653 100644
--- a/src/librustdoc/html/static/js/main.js
+++ b/src/librustdoc/html/static/js/main.js
@@ -1855,8 +1855,13 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
         // Since the button will be added, no need to keep this listener around.
         elem.removeEventListener("mouseover", addCopyButton);
 
-        const parent = document.createElement("div");
-        parent.className = "button-holder";
+        // If this is a scrapped example, there will already be a "button-holder" element.
+        let parent = elem.querySelector(".button-holder");
+        if (!parent) {
+            parent = document.createElement("div");
+            parent.className = "button-holder";
+        }
+
         const runButton = elem.querySelector(".test-arrow");
         if (runButton !== null) {
             // If there is a run button, we move it into the same div.