diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 462a696dee6..baf32ab9cb2 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1396,8 +1396,8 @@ function defocusSearchBar() { // "current" is used to know which tab we're looking into. var current = 0; onEachLazy(document.getElementById("results").childNodes, function(e) { - onEachLazy(e.getElementsByClassName("highlighted"), function(e) { - actives[current].push(e); + onEachLazy(e.getElementsByClassName("highlighted"), function(h_e) { + actives[current].push(h_e); }); current += 1; }); @@ -2113,8 +2113,12 @@ function defocusSearchBar() { } } + function getToggleAllDocsElement() { + return document.getElementById("toggle-all-docs"); + } + function toggleAllDocs(pageId, fromAutoCollapse) { - var innerToggle = document.getElementById("toggle-all-docs"); + var innerToggle = getToggleAllDocsElement(); if (!innerToggle) { return; } @@ -2307,11 +2311,6 @@ function defocusSearchBar() { } } - var toggles = document.getElementById("toggle-all-docs"); - if (toggles) { - toggles.onclick = toggleAllDocs; - } - function insertAfter(newNode, referenceNode) { referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); } @@ -2361,6 +2360,11 @@ function defocusSearchBar() { } (function() { + var toggles = document.getElementById("toggle-all-docs"); + if (toggles) { + toggles.onclick = toggleAllDocs; + } + var toggle = createSimpleToggle(false); var hideMethodDocs = getCurrentValue("rustdoc-auto-hide-method-docs") === "true"; var hideImplementors = getCurrentValue("rustdoc-auto-collapse-implementors") !== "false";