Skip to content

Commit

Permalink
Rollup merge of #128573 - GuillaumeGomez:simplify-body, r=notriddle
Browse files Browse the repository at this point in the history
Simplify `body` usage in rustdoc

No changes, just a little less code.

r? `@notriddle`
  • Loading branch information
matthiaskrgr authored Aug 3, 2024
2 parents 0613381 + a3a09b4 commit e488ee7
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1114,8 +1114,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;
Expand Down Expand Up @@ -1234,8 +1233,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;
}
Expand Down Expand Up @@ -1832,7 +1830,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;
}
}
Expand Down

0 comments on commit e488ee7

Please sign in to comment.