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