Skip to content

Commit

Permalink
Rollup merge of rust-lang#82807 - notriddle:cleanup-js, r=jyn514
Browse files Browse the repository at this point in the history
rustdoc: 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.
  • Loading branch information
Dylan-DPC authored Mar 10, 2021
2 parents 759204f + 28135b7 commit 9ac57b1
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2188,7 +2188,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
}

Expand Down Expand Up @@ -2831,17 +2831,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");
Expand All @@ -2860,7 +2853,6 @@ function defocusSearchBar() {
elem.value = savedCrate;
}
}
enableSearchInput();
};

function buildHelperPopup() {
Expand Down Expand Up @@ -2952,7 +2944,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);
Expand Down

0 comments on commit 9ac57b1

Please sign in to comment.