Skip to content

Commit a3a09b4

Browse files
Simplify body usage in rustdoc
1 parent e552c16 commit a3a09b4

File tree

1 file changed

+3
-5
lines changed
  • src/librustdoc/html/static/js

1 file changed

+3
-5
lines changed

src/librustdoc/html/static/js/main.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1115,8 +1115,7 @@ function preLoadCss(cssUrl) {
11151115
wrapper.style.left = 0;
11161116
wrapper.style.right = "auto";
11171117
wrapper.style.visibility = "hidden";
1118-
const body = document.getElementsByTagName("body")[0];
1119-
body.appendChild(wrapper);
1118+
document.body.appendChild(wrapper);
11201119
const wrapperPos = wrapper.getBoundingClientRect();
11211120
// offset so that the arrow points at the center of the "(i)"
11221121
const finalPos = pos.left + window.scrollX - wrapperPos.width + 24;
@@ -1235,8 +1234,7 @@ function preLoadCss(cssUrl) {
12351234
}
12361235
window.CURRENT_TOOLTIP_ELEMENT.TOOLTIP_BASE.TOOLTIP_FORCE_VISIBLE = false;
12371236
}
1238-
const body = document.getElementsByTagName("body")[0];
1239-
body.removeChild(window.CURRENT_TOOLTIP_ELEMENT);
1237+
document.body.removeChild(window.CURRENT_TOOLTIP_ELEMENT);
12401238
clearTooltipHoverTimeout(window.CURRENT_TOOLTIP_ELEMENT);
12411239
window.CURRENT_TOOLTIP_ELEMENT = null;
12421240
}
@@ -1833,7 +1831,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
18331831
let elem = event.target;
18341832
while (!hasClass(elem, "example-wrap")) {
18351833
elem = elem.parentElement;
1836-
if (elem.tagName === "body" || hasClass(elem, "docblock")) {
1834+
if (elem === document.body || hasClass(elem, "docblock")) {
18371835
return null;
18381836
}
18391837
}

0 commit comments

Comments
 (0)