@@ -4713,7 +4713,6 @@ function printTab(nb) {
4713
4713
iter += 1 ;
4714
4714
} ) ;
4715
4715
if ( foundCurrentTab && foundCurrentResultSet ) {
4716
- // @ts -expect-error
4717
4716
searchState . currentTab = nb ;
4718
4717
// Corrections only kick in on type-based searches.
4719
4718
const correctionsElem = document . getElementsByClassName ( "search-corrections" ) ;
@@ -4766,7 +4765,6 @@ function getFilterCrates() {
4766
4765
4767
4766
// @ts -expect-error
4768
4767
function nextTab ( direction ) {
4769
- // @ts -expect-error
4770
4768
const next = ( searchState . currentTab + direction + 3 ) % searchState . focusedByTab . length ;
4771
4769
// @ts -expect-error
4772
4770
searchState . focusedByTab [ searchState . currentTab ] = document . activeElement ;
@@ -4777,14 +4775,12 @@ function nextTab(direction) {
4777
4775
// Focus the first search result on the active tab, or the result that
4778
4776
// was focused last time this tab was active.
4779
4777
function focusSearchResult ( ) {
4780
- // @ts -expect-error
4781
4778
const target = searchState . focusedByTab [ searchState . currentTab ] ||
4782
4779
document . querySelectorAll ( ".search-results.active a" ) . item ( 0 ) ||
4783
- // @ts -expect-error
4784
4780
document . querySelectorAll ( "#search-tabs button" ) . item ( searchState . currentTab ) ;
4785
- // @ts -expect-error
4786
4781
searchState . focusedByTab [ searchState . currentTab ] = null ;
4787
4782
if ( target ) {
4783
+ // @ts -expect-error
4788
4784
target . focus ( ) ;
4789
4785
}
4790
4786
}
@@ -4936,7 +4932,6 @@ function makeTabHeader(tabNb, text, nbElems) {
4936
4932
const fmtNbElems =
4937
4933
nbElems < 10 ? `\u{2007}(${ nbElems } )\u{2007}\u{2007}` :
4938
4934
nbElems < 100 ? `\u{2007}(${ nbElems } )\u{2007}` : `\u{2007}(${ nbElems } )` ;
4939
- // @ts -expect-error
4940
4935
if ( searchState . currentTab === tabNb ) {
4941
4936
return "<button class=\"selected\">" + text +
4942
4937
"<span class=\"count\">" + fmtNbElems + "</span></button>" ;
@@ -4950,7 +4945,6 @@ function makeTabHeader(tabNb, text, nbElems) {
4950
4945
* @param {string } filterCrates
4951
4946
*/
4952
4947
async function showResults ( results , go_to_first , filterCrates ) {
4953
- // @ts -expect-error
4954
4948
const search = searchState . outputElement ( ) ;
4955
4949
if ( go_to_first || ( results . others . length === 1
4956
4950
&& getSettingValue ( "go-to-only-result" ) === "true" )
@@ -4968,7 +4962,6 @@ async function showResults(results, go_to_first, filterCrates) {
4968
4962
// will be used, starting search again since the search input is not empty, leading you
4969
4963
// back to the previous page again.
4970
4964
window . onunload = ( ) => { } ;
4971
- // @ts -expect-error
4972
4965
searchState . removeQueryParameters ( ) ;
4973
4966
const elem = document . createElement ( "a" ) ;
4974
4967
elem . href = results . others [ 0 ] . href ;
@@ -4988,7 +4981,6 @@ async function showResults(results, go_to_first, filterCrates) {
4988
4981
// Navigate to the relevant tab if the current tab is empty, like in case users search
4989
4982
// for "-> String". If they had selected another tab previously, they have to click on
4990
4983
// it again.
4991
- // @ts -expect-error
4992
4984
let currentTab = searchState . currentTab ;
4993
4985
if ( ( currentTab === 0 && results . others . length === 0 ) ||
4994
4986
( currentTab === 1 && results . in_args . length === 0 ) ||
@@ -5076,8 +5068,8 @@ async function showResults(results, go_to_first, filterCrates) {
5076
5068
resultsElem . appendChild ( ret_in_args ) ;
5077
5069
resultsElem . appendChild ( ret_returned ) ;
5078
5070
5079
- search . innerHTML = output ;
5080
5071
// @ts -expect-error
5072
+ search . innerHTML = output ;
5081
5073
if ( searchState . rustdocToolbar ) {
5082
5074
// @ts -expect-error
5083
5075
search . querySelector ( ".main-heading" ) . appendChild ( searchState . rustdocToolbar ) ;
@@ -5086,9 +5078,9 @@ async function showResults(results, go_to_first, filterCrates) {
5086
5078
if ( crateSearch ) {
5087
5079
crateSearch . addEventListener ( "input" , updateCrate ) ;
5088
5080
}
5081
+ // @ts -expect-error
5089
5082
search . appendChild ( resultsElem ) ;
5090
5083
// Reset focused elements.
5091
- // @ts -expect-error
5092
5084
searchState . showResults ( search ) ;
5093
5085
// @ts -expect-error
5094
5086
const elems = document . getElementById ( "search-tabs" ) . childNodes ;
@@ -5099,7 +5091,6 @@ async function showResults(results, go_to_first, filterCrates) {
5099
5091
const j = i ;
5100
5092
// @ts -expect-error
5101
5093
elem . onclick = ( ) => printTab ( j ) ;
5102
- // @ts -expect-error
5103
5094
searchState . focusedByTab . push ( null ) ;
5104
5095
i += 1 ;
5105
5096
}
@@ -5111,7 +5102,6 @@ function updateSearchHistory(url) {
5111
5102
if ( ! browserSupportsHistoryApi ( ) ) {
5112
5103
return ;
5113
5104
}
5114
- // @ts -expect-error
5115
5105
const params = searchState . getQueryStringParams ( ) ;
5116
5106
if ( ! history . state && ! params . search ) {
5117
5107
history . pushState ( null , "" , url ) ;
@@ -5138,10 +5128,8 @@ async function search(forced) {
5138
5128
return ;
5139
5129
}
5140
5130
5141
- // @ts -expect-error
5142
5131
searchState . setLoadingSearch ( ) ;
5143
5132
5144
- // @ts -expect-error
5145
5133
const params = searchState . getQueryStringParams ( ) ;
5146
5134
5147
5135
// In case we have no information about the saved crate and there is a URL query parameter,
@@ -5151,7 +5139,6 @@ async function search(forced) {
5151
5139
}
5152
5140
5153
5141
// Update document title to maintain a meaningful browser history
5154
- // @ts -expect-error
5155
5142
searchState . title = "\"" + query . userQuery + "\" Search - Rust" ;
5156
5143
5157
5144
// Because searching is incremental by character, only the most
@@ -5173,33 +5160,28 @@ async function search(forced) {
5173
5160
function onSearchSubmit ( e ) {
5174
5161
// @ts -expect-error
5175
5162
e . preventDefault ( ) ;
5176
- // @ts -expect-error
5177
5163
searchState . clearInputTimeout ( ) ;
5178
5164
search ( ) ;
5179
5165
}
5180
5166
5181
5167
function putBackSearch ( ) {
5182
- // @ts -expect-error
5183
5168
const search_input = searchState . input ;
5184
- // @ts -expect-error
5185
5169
if ( ! searchState . input ) {
5186
5170
return ;
5187
5171
}
5188
5172
// @ts -expect-error
5189
5173
if ( search_input . value !== "" && ! searchState . isDisplayed ( ) ) {
5190
- // @ts -expect-error
5191
5174
searchState . showResults ( ) ;
5192
5175
if ( browserSupportsHistoryApi ( ) ) {
5193
5176
history . replaceState ( null , "" ,
5177
+ // @ts -expect-error
5194
5178
buildUrl ( search_input . value , getFilterCrates ( ) ) ) ;
5195
5179
}
5196
- // @ts -expect-error
5197
5180
document . title = searchState . title ;
5198
5181
}
5199
5182
}
5200
5183
5201
5184
function registerSearchEvents ( ) {
5202
- // @ts -expect-error
5203
5185
const params = searchState . getQueryStringParams ( ) ;
5204
5186
5205
5187
// Populate search bar with query string search term when provided,
@@ -5213,11 +5195,9 @@ function registerSearchEvents() {
5213
5195
}
5214
5196
5215
5197
const searchAfter500ms = ( ) => {
5216
- // @ts -expect-error
5217
5198
searchState . clearInputTimeout ( ) ;
5218
5199
// @ts -expect-error
5219
5200
if ( searchState . input . value . length === 0 ) {
5220
- // @ts -expect-error
5221
5201
searchState . hideResults ( ) ;
5222
5202
} else {
5223
5203
// @ts -expect-error
@@ -5237,7 +5217,6 @@ function registerSearchEvents() {
5237
5217
return ;
5238
5218
}
5239
5219
// Do NOT e.preventDefault() here. It will prevent pasting.
5240
- // @ts -expect-error
5241
5220
searchState . clearInputTimeout ( ) ;
5242
5221
// zero-timeout necessary here because at the time of event handler execution the
5243
5222
// pasted content is not in the input field yet. Shouldn’t make any difference for
@@ -5263,7 +5242,6 @@ function registerSearchEvents() {
5263
5242
// @ts -expect-error
5264
5243
previous . focus ( ) ;
5265
5244
} else {
5266
- // @ts -expect-error
5267
5245
searchState . focus ( ) ;
5268
5246
}
5269
5247
e . preventDefault ( ) ;
@@ -5316,7 +5294,6 @@ function registerSearchEvents() {
5316
5294
const previousTitle = document . title ;
5317
5295
5318
5296
window . addEventListener ( "popstate" , e => {
5319
- // @ts -expect-error
5320
5297
const params = searchState . getQueryStringParams ( ) ;
5321
5298
// Revert to the previous title manually since the History
5322
5299
// API ignores the title parameter.
@@ -5344,7 +5321,6 @@ function registerSearchEvents() {
5344
5321
searchState . input . value = "" ;
5345
5322
// When browsing back from search results the main page
5346
5323
// visibility must be reset.
5347
- // @ts -expect-error
5348
5324
searchState . hideResults ( ) ;
5349
5325
}
5350
5326
} ) ;
@@ -5357,7 +5333,6 @@ function registerSearchEvents() {
5357
5333
// that try to sync state between the URL and the search input. To work around it,
5358
5334
// do a small amount of re-init on page show.
5359
5335
window . onpageshow = ( ) => {
5360
- // @ts -expect-error
5361
5336
const qSearch = searchState . getQueryStringParams ( ) . search ;
5362
5337
// @ts -expect-error
5363
5338
if ( searchState . input . value === "" && qSearch ) {
0 commit comments