about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2024-08-03 00:14:45 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2024-08-03 15:37:27 +0200
commita3a09b488fde8fbe66c2be44491cdb87201d32a2 (patch)
tree25fa58761630c22124625beb2adf6788526691c8 /src
parente552c168c72c95dc28950a9aae8ed7030199aa0d (diff)
downloadrust-a3a09b488fde8fbe66c2be44491cdb87201d32a2.tar.gz
rust-a3a09b488fde8fbe66c2be44491cdb87201d32a2.zip
Simplify `body` usage in rustdoc
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/html/static/js/main.js8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js
index e0ea234f9e7..ee771a40595 100644
--- a/src/librustdoc/html/static/js/main.js
+++ b/src/librustdoc/html/static/js/main.js
@@ -1115,8 +1115,7 @@ function preLoadCss(cssUrl) {
         wrapper.style.left = 0;
         wrapper.style.right = "auto";
         wrapper.style.visibility = "hidden";
-        const body = document.getElementsByTagName("body")[0];
-        body.appendChild(wrapper);
+        document.body.appendChild(wrapper);
         const wrapperPos = wrapper.getBoundingClientRect();
         // offset so that the arrow points at the center of the "(i)"
         const finalPos = pos.left + window.scrollX - wrapperPos.width + 24;
@@ -1235,8 +1234,7 @@ function preLoadCss(cssUrl) {
                 }
                 window.CURRENT_TOOLTIP_ELEMENT.TOOLTIP_BASE.TOOLTIP_FORCE_VISIBLE = false;
             }
-            const body = document.getElementsByTagName("body")[0];
-            body.removeChild(window.CURRENT_TOOLTIP_ELEMENT);
+            document.body.removeChild(window.CURRENT_TOOLTIP_ELEMENT);
             clearTooltipHoverTimeout(window.CURRENT_TOOLTIP_ELEMENT);
             window.CURRENT_TOOLTIP_ELEMENT = null;
         }
@@ -1833,7 +1831,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
         let elem = event.target;
         while (!hasClass(elem, "example-wrap")) {
             elem = elem.parentElement;
-            if (elem.tagName === "body" || hasClass(elem, "docblock")) {
+            if (elem === document.body || hasClass(elem, "docblock")) {
                 return null;
             }
         }