Skip to content

Commit e698de9

Browse files
Rollup merge of #118291 - notriddle:notriddle/search-dom, r=GuillaumeGomez
rustdoc-search: clean up some DOM code
2 parents 9b1da03 + 884679f commit e698de9

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/librustdoc/html/static/js/search.js

+5-11
Original file line numberDiff line numberDiff line change
@@ -2424,10 +2424,7 @@ function initSearch(rawSearchIndex) {
24242424
* @param {boolean} display - True if this is the active tab
24252425
*/
24262426
function addTab(array, query, display) {
2427-
let extraClass = "";
2428-
if (display === true) {
2429-
extraClass = " active";
2430-
}
2427+
const extraClass = display ? " active" : "";
24312428

24322429
const output = document.createElement("div");
24332430
let length = 0;
@@ -2669,13 +2666,9 @@ ${item.displayPath}<span class="${type}">${name}</span>\
26692666
/**
26702667
* Perform a search based on the current state of the search input element
26712668
* and display the results.
2672-
* @param {Event} [e] - The event that triggered this search, if any
26732669
* @param {boolean} [forced]
26742670
*/
2675-
function search(e, forced) {
2676-
if (e) {
2677-
e.preventDefault();
2678-
}
2671+
function search(forced) {
26792672
const query = parseQuery(searchState.input.value.trim());
26802673
let filterCrates = getFilterCrates();
26812674

@@ -3212,7 +3205,8 @@ ${item.displayPath}<span class="${type}">${name}</span>\
32123205
// popping a state (Firefox), which is why search() is
32133206
// called both here and at the end of the startSearch()
32143207
// function.
3215-
search(e);
3208+
e.preventDefault();
3209+
search();
32163210
} else {
32173211
searchState.input.value = "";
32183212
// When browsing back from search results the main page
@@ -3247,7 +3241,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
32473241
// before paste back the previous search, you get the old search results without
32483242
// the filter. To prevent this, we need to remove the previous results.
32493243
currentResults = null;
3250-
search(undefined, true);
3244+
search(true);
32513245
}
32523246

32533247
/**

0 commit comments

Comments
 (0)