diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 4d44b85ad65bc..ec8024ffca529 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -493,11 +493,7 @@ function defocusSearchBar() {
document.addEventListener("keypress", handleShortcut);
document.addEventListener("keydown", handleShortcut);
- function resetMouseMoved(ev) {
- mouseMovedAfterSearch = true;
- }
-
- document.addEventListener("mousemove", resetMouseMoved);
+ document.addEventListener("mousemove", function() { mouseMovedAfterSearch = true; });
var handleSourceHighlight = (function() {
var prev_line_id = 0;
@@ -2151,14 +2147,14 @@ function defocusSearchBar() {
var code = document.createElement("code");
code.innerHTML = struct.text;
- var x = code.getElementsByTagName("a");
- var xlength = x.length;
- for (var it = 0; it < xlength; it++) {
- var href = x[it].getAttribute("href");
+ onEachLazy(code.getElementsByTagName("a"), function(elem) {
+ var href = elem.getAttribute("href");
+
if (href && href.indexOf("http") !== 0) {
- x[it].setAttribute("href", rootPath + href);
+ elem.setAttribute("href", rootPath + href);
}
- }
+ });
+
var display = document.createElement("h3");
addClass(display, "impl");
display.innerHTML = "" +
@@ -2547,14 +2543,12 @@ function defocusSearchBar() {
var hiddenElems = e.getElementsByClassName("hidden");
var needToggle = false;
- var hlength = hiddenElems.length;
- for (var i = 0; i < hlength; ++i) {
- if (hasClass(hiddenElems[i], "content") === false &&
- hasClass(hiddenElems[i], "docblock") === false) {
- needToggle = true;
- break;
+ var needToggle = onEachLazy(e.getElementsByClassName("hidden"), function(hiddenElem) {
+ if (hasClass(hiddenElem, "content") === false &&
+ hasClass(hiddenElem, "docblock") === false) {
+ return true;
}
- }
+ });
if (needToggle === true) {
var inner_toggle = newToggle.cloneNode(true);
inner_toggle.onclick = toggleClicked;