From 28135b79d71e4256f9f0ac76aa8c6c49b3127d09 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 5 Mar 2021 10:04:33 -0700 Subject: [PATCH] Remove redundant enableSearchInput function enableSearchInput was called from two places: - setupSearchLoader - addSearchOptions, which is itself called from setupSearchLoader only This commit can safely get rid of the addSearchOptions calls entirely, and since the setupSearchLoader call is immediately preceded by other method calls on search_input, there's no need to check if it's set. --- src/librustdoc/html/static/main.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 89b1362b32b63..965db73db0a13 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -2208,7 +2208,7 @@ function defocusSearchBar() { return "+"; } // button will collapse the section - // note that this text is also set in the HTML template in render.rs + // note that this text is also set in the HTML template in ../render/mod.rs return "\u2212"; // "\u2212" is "−" minus sign } @@ -2851,17 +2851,10 @@ function defocusSearchBar() { }); } - function enableSearchInput() { - if (search_input) { - search_input.removeAttribute('disabled'); - } - } - function addSearchOptions(crates) { var elem = document.getElementById("crate-search"); if (!elem) { - enableSearchInput(); return; } var savedCrate = getSettingValue("saved-filter-crate"); @@ -2880,7 +2873,6 @@ function defocusSearchBar() { elem.value = savedCrate; } } - enableSearchInput(); }; function buildHelperPopup() { @@ -2972,7 +2964,7 @@ function defocusSearchBar() { search_input.addEventListener("blur", function() { search_input.placeholder = search_input.origPlaceholder; }); - enableSearchInput(); + search_input.removeAttribute('disabled'); var crateSearchDropDown = document.getElementById("crate-search"); crateSearchDropDown.addEventListener("focus", loadSearch);