rustdoc-search: clean up some DOM code
This commit is contained in:
parent
fe3038f263
commit
884679ff63
@ -2424,10 +2424,7 @@ function initSearch(rawSearchIndex) {
|
|||||||
* @param {boolean} display - True if this is the active tab
|
* @param {boolean} display - True if this is the active tab
|
||||||
*/
|
*/
|
||||||
function addTab(array, query, display) {
|
function addTab(array, query, display) {
|
||||||
let extraClass = "";
|
const extraClass = display ? " active" : "";
|
||||||
if (display === true) {
|
|
||||||
extraClass = " active";
|
|
||||||
}
|
|
||||||
|
|
||||||
const output = document.createElement("div");
|
const output = document.createElement("div");
|
||||||
let length = 0;
|
let length = 0;
|
||||||
@ -2669,13 +2666,9 @@ ${item.displayPath}<span class="${type}">${name}</span>\
|
|||||||
/**
|
/**
|
||||||
* Perform a search based on the current state of the search input element
|
* Perform a search based on the current state of the search input element
|
||||||
* and display the results.
|
* and display the results.
|
||||||
* @param {Event} [e] - The event that triggered this search, if any
|
|
||||||
* @param {boolean} [forced]
|
* @param {boolean} [forced]
|
||||||
*/
|
*/
|
||||||
function search(e, forced) {
|
function search(forced) {
|
||||||
if (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
const query = parseQuery(searchState.input.value.trim());
|
const query = parseQuery(searchState.input.value.trim());
|
||||||
let filterCrates = getFilterCrates();
|
let filterCrates = getFilterCrates();
|
||||||
|
|
||||||
@ -3212,7 +3205,8 @@ ${item.displayPath}<span class="${type}">${name}</span>\
|
|||||||
// popping a state (Firefox), which is why search() is
|
// popping a state (Firefox), which is why search() is
|
||||||
// called both here and at the end of the startSearch()
|
// called both here and at the end of the startSearch()
|
||||||
// function.
|
// function.
|
||||||
search(e);
|
e.preventDefault();
|
||||||
|
search();
|
||||||
} else {
|
} else {
|
||||||
searchState.input.value = "";
|
searchState.input.value = "";
|
||||||
// When browsing back from search results the main page
|
// When browsing back from search results the main page
|
||||||
@ -3247,7 +3241,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
|
|||||||
// before paste back the previous search, you get the old search results without
|
// before paste back the previous search, you get the old search results without
|
||||||
// the filter. To prevent this, we need to remove the previous results.
|
// the filter. To prevent this, we need to remove the previous results.
|
||||||
currentResults = null;
|
currentResults = null;
|
||||||
search(undefined, true);
|
search(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user