@@ -4713,7 +4713,6 @@ function printTab(nb) {
47134713 iter += 1 ;
47144714 } ) ;
47154715 if ( foundCurrentTab && foundCurrentResultSet ) {
4716- // @ts -expect-error
47174716 searchState . currentTab = nb ;
47184717 // Corrections only kick in on type-based searches.
47194718 const correctionsElem = document . getElementsByClassName ( "search-corrections" ) ;
@@ -4766,7 +4765,6 @@ function getFilterCrates() {
47664765
47674766// @ts -expect-error
47684767function nextTab ( direction ) {
4769- // @ts -expect-error
47704768 const next = ( searchState . currentTab + direction + 3 ) % searchState . focusedByTab . length ;
47714769 // @ts -expect-error
47724770 searchState . focusedByTab [ searchState . currentTab ] = document . activeElement ;
@@ -4777,14 +4775,12 @@ function nextTab(direction) {
47774775// Focus the first search result on the active tab, or the result that
47784776// was focused last time this tab was active.
47794777function focusSearchResult ( ) {
4780- // @ts -expect-error
47814778 const target = searchState . focusedByTab [ searchState . currentTab ] ||
47824779 document . querySelectorAll ( ".search-results.active a" ) . item ( 0 ) ||
4783- // @ts -expect-error
47844780 document . querySelectorAll ( "#search-tabs button" ) . item ( searchState . currentTab ) ;
4785- // @ts -expect-error
47864781 searchState . focusedByTab [ searchState . currentTab ] = null ;
47874782 if ( target ) {
4783+ // @ts -expect-error
47884784 target . focus ( ) ;
47894785 }
47904786}
@@ -4936,7 +4932,6 @@ function makeTabHeader(tabNb, text, nbElems) {
49364932 const fmtNbElems =
49374933 nbElems < 10 ? `\u{2007}(${ nbElems } )\u{2007}\u{2007}` :
49384934 nbElems < 100 ? `\u{2007}(${ nbElems } )\u{2007}` : `\u{2007}(${ nbElems } )` ;
4939- // @ts -expect-error
49404935 if ( searchState . currentTab === tabNb ) {
49414936 return "<button class=\"selected\">" + text +
49424937 "<span class=\"count\">" + fmtNbElems + "</span></button>" ;
@@ -4950,7 +4945,6 @@ function makeTabHeader(tabNb, text, nbElems) {
49504945 * @param {string } filterCrates
49514946 */
49524947async function showResults ( results , go_to_first , filterCrates ) {
4953- // @ts -expect-error
49544948 const search = searchState . outputElement ( ) ;
49554949 if ( go_to_first || ( results . others . length === 1
49564950 && getSettingValue ( "go-to-only-result" ) === "true" )
@@ -4968,7 +4962,6 @@ async function showResults(results, go_to_first, filterCrates) {
49684962 // will be used, starting search again since the search input is not empty, leading you
49694963 // back to the previous page again.
49704964 window . onunload = ( ) => { } ;
4971- // @ts -expect-error
49724965 searchState . removeQueryParameters ( ) ;
49734966 const elem = document . createElement ( "a" ) ;
49744967 elem . href = results . others [ 0 ] . href ;
@@ -4988,7 +4981,6 @@ async function showResults(results, go_to_first, filterCrates) {
49884981 // Navigate to the relevant tab if the current tab is empty, like in case users search
49894982 // for "-> String". If they had selected another tab previously, they have to click on
49904983 // it again.
4991- // @ts -expect-error
49924984 let currentTab = searchState . currentTab ;
49934985 if ( ( currentTab === 0 && results . others . length === 0 ) ||
49944986 ( currentTab === 1 && results . in_args . length === 0 ) ||
@@ -5076,8 +5068,8 @@ async function showResults(results, go_to_first, filterCrates) {
50765068 resultsElem . appendChild ( ret_in_args ) ;
50775069 resultsElem . appendChild ( ret_returned ) ;
50785070
5079- search . innerHTML = output ;
50805071 // @ts -expect-error
5072+ search . innerHTML = output ;
50815073 if ( searchState . rustdocToolbar ) {
50825074 // @ts -expect-error
50835075 search . querySelector ( ".main-heading" ) . appendChild ( searchState . rustdocToolbar ) ;
@@ -5086,9 +5078,9 @@ async function showResults(results, go_to_first, filterCrates) {
50865078 if ( crateSearch ) {
50875079 crateSearch . addEventListener ( "input" , updateCrate ) ;
50885080 }
5081+ // @ts -expect-error
50895082 search . appendChild ( resultsElem ) ;
50905083 // Reset focused elements.
5091- // @ts -expect-error
50925084 searchState . showResults ( search ) ;
50935085 // @ts -expect-error
50945086 const elems = document . getElementById ( "search-tabs" ) . childNodes ;
@@ -5099,7 +5091,6 @@ async function showResults(results, go_to_first, filterCrates) {
50995091 const j = i ;
51005092 // @ts -expect-error
51015093 elem . onclick = ( ) => printTab ( j ) ;
5102- // @ts -expect-error
51035094 searchState . focusedByTab . push ( null ) ;
51045095 i += 1 ;
51055096 }
@@ -5111,7 +5102,6 @@ function updateSearchHistory(url) {
51115102 if ( ! browserSupportsHistoryApi ( ) ) {
51125103 return ;
51135104 }
5114- // @ts -expect-error
51155105 const params = searchState . getQueryStringParams ( ) ;
51165106 if ( ! history . state && ! params . search ) {
51175107 history . pushState ( null , "" , url ) ;
@@ -5138,10 +5128,8 @@ async function search(forced) {
51385128 return ;
51395129 }
51405130
5141- // @ts -expect-error
51425131 searchState . setLoadingSearch ( ) ;
51435132
5144- // @ts -expect-error
51455133 const params = searchState . getQueryStringParams ( ) ;
51465134
51475135 // 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) {
51515139 }
51525140
51535141 // Update document title to maintain a meaningful browser history
5154- // @ts -expect-error
51555142 searchState . title = "\"" + query . userQuery + "\" Search - Rust" ;
51565143
51575144 // Because searching is incremental by character, only the most
@@ -5173,33 +5160,28 @@ async function search(forced) {
51735160function onSearchSubmit ( e ) {
51745161 // @ts -expect-error
51755162 e . preventDefault ( ) ;
5176- // @ts -expect-error
51775163 searchState . clearInputTimeout ( ) ;
51785164 search ( ) ;
51795165}
51805166
51815167function putBackSearch ( ) {
5182- // @ts -expect-error
51835168 const search_input = searchState . input ;
5184- // @ts -expect-error
51855169 if ( ! searchState . input ) {
51865170 return ;
51875171 }
51885172 // @ts -expect-error
51895173 if ( search_input . value !== "" && ! searchState . isDisplayed ( ) ) {
5190- // @ts -expect-error
51915174 searchState . showResults ( ) ;
51925175 if ( browserSupportsHistoryApi ( ) ) {
51935176 history . replaceState ( null , "" ,
5177+ // @ts -expect-error
51945178 buildUrl ( search_input . value , getFilterCrates ( ) ) ) ;
51955179 }
5196- // @ts -expect-error
51975180 document . title = searchState . title ;
51985181 }
51995182}
52005183
52015184function registerSearchEvents ( ) {
5202- // @ts -expect-error
52035185 const params = searchState . getQueryStringParams ( ) ;
52045186
52055187 // Populate search bar with query string search term when provided,
@@ -5213,11 +5195,9 @@ function registerSearchEvents() {
52135195 }
52145196
52155197 const searchAfter500ms = ( ) => {
5216- // @ts -expect-error
52175198 searchState . clearInputTimeout ( ) ;
52185199 // @ts -expect-error
52195200 if ( searchState . input . value . length === 0 ) {
5220- // @ts -expect-error
52215201 searchState . hideResults ( ) ;
52225202 } else {
52235203 // @ts -expect-error
@@ -5237,7 +5217,6 @@ function registerSearchEvents() {
52375217 return ;
52385218 }
52395219 // Do NOT e.preventDefault() here. It will prevent pasting.
5240- // @ts -expect-error
52415220 searchState . clearInputTimeout ( ) ;
52425221 // zero-timeout necessary here because at the time of event handler execution the
52435222 // pasted content is not in the input field yet. Shouldn’t make any difference for
@@ -5263,7 +5242,6 @@ function registerSearchEvents() {
52635242 // @ts -expect-error
52645243 previous . focus ( ) ;
52655244 } else {
5266- // @ts -expect-error
52675245 searchState . focus ( ) ;
52685246 }
52695247 e . preventDefault ( ) ;
@@ -5316,7 +5294,6 @@ function registerSearchEvents() {
53165294 const previousTitle = document . title ;
53175295
53185296 window . addEventListener ( "popstate" , e => {
5319- // @ts -expect-error
53205297 const params = searchState . getQueryStringParams ( ) ;
53215298 // Revert to the previous title manually since the History
53225299 // API ignores the title parameter.
@@ -5344,7 +5321,6 @@ function registerSearchEvents() {
53445321 searchState . input . value = "" ;
53455322 // When browsing back from search results the main page
53465323 // visibility must be reset.
5347- // @ts -expect-error
53485324 searchState . hideResults ( ) ;
53495325 }
53505326 } ) ;
@@ -5357,7 +5333,6 @@ function registerSearchEvents() {
53575333 // that try to sync state between the URL and the search input. To work around it,
53585334 // do a small amount of re-init on page show.
53595335 window . onpageshow = ( ) => {
5360- // @ts -expect-error
53615336 const qSearch = searchState . getQueryStringParams ( ) . search ;
53625337 // @ts -expect-error
53635338 if ( searchState . input . value === "" && qSearch ) {
0 commit comments