Skip to content

Commit 3cc223c

Browse files
authored
Unrolled build for rust-lang#128573
Rollup merge of rust-lang#128573 - GuillaumeGomez:simplify-body, r=notriddle Simplify `body` usage in rustdoc No changes, just a little less code. r? `@notriddle`
2 parents bbf60c8 + a3a09b4 commit 3cc223c

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
@@ -1114,8 +1114,7 @@ function preLoadCss(cssUrl) {
11141114
wrapper.style.left = 0;
11151115
wrapper.style.right = "auto";
11161116
wrapper.style.visibility = "hidden";
1117-
const body = document.getElementsByTagName("body")[0];
1118-
body.appendChild(wrapper);
1117+
document.body.appendChild(wrapper);
11191118
const wrapperPos = wrapper.getBoundingClientRect();
11201119
// offset so that the arrow points at the center of the "(i)"
11211120
const finalPos = pos.left + window.scrollX - wrapperPos.width + 24;
@@ -1234,8 +1233,7 @@ function preLoadCss(cssUrl) {
12341233
}
12351234
window.CURRENT_TOOLTIP_ELEMENT.TOOLTIP_BASE.TOOLTIP_FORCE_VISIBLE = false;
12361235
}
1237-
const body = document.getElementsByTagName("body")[0];
1238-
body.removeChild(window.CURRENT_TOOLTIP_ELEMENT);
1236+
document.body.removeChild(window.CURRENT_TOOLTIP_ELEMENT);
12391237
clearTooltipHoverTimeout(window.CURRENT_TOOLTIP_ELEMENT);
12401238
window.CURRENT_TOOLTIP_ELEMENT = null;
12411239
}
@@ -1832,7 +1830,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
18321830
let elem = event.target;
18331831
while (!hasClass(elem, "example-wrap")) {
18341832
elem = elem.parentElement;
1835-
if (elem.tagName === "body" || hasClass(elem, "docblock")) {
1833+
if (elem === document.body || hasClass(elem, "docblock")) {
18361834
return null;
18371835
}
18381836
}

0 commit comments

Comments
 (0)