Skip to content

Commit

Permalink
Auto merge of #83028 - GuillaumeGomez:prevent-js-error-if-no-filter, …
Browse files Browse the repository at this point in the history
…r=Nemo157

Prevent JS error when there is no dependency or other crate documented (or --disable-per-crate-search has been used)

When there is only one crate, the dropdown is removed, creating an error (that you can see pretty easily on docs.rs for example).

r? `@jyn514`
  • Loading branch information
bors committed Mar 14, 2021
2 parents 1381dcf + 56898ec commit 2caeeb0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2948,7 +2948,11 @@ function defocusSearchBar() {
search_input.removeAttribute('disabled');

var crateSearchDropDown = document.getElementById("crate-search");
crateSearchDropDown.addEventListener("focus", loadSearch);
// `crateSearchDropDown` can be null in case there is only crate because in that case, the
// crate filter dropdown is removed.
if (crateSearchDropDown) {
crateSearchDropDown.addEventListener("focus", loadSearch);
}
var params = getQueryStringParams();
if (params.search !== undefined) {
loadSearch();
Expand Down

0 comments on commit 2caeeb0

Please sign in to comment.