This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
src/librustdoc/html/static/js Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -185,9 +185,12 @@ function preLoadCss(cssUrl) {
185185( function ( ) {
186186 const isHelpPage = window . location . pathname . endsWith ( "/help.html" ) ;
187187
188- function loadScript ( url ) {
188+ function loadScript ( url , errorCallback ) {
189189 const script = document . createElement ( "script" ) ;
190190 script . src = url ;
191+ if ( errorCallback !== undefined ) {
192+ script . onerror = errorCallback ;
193+ }
191194 document . head . append ( script ) ;
192195 }
193196
@@ -292,11 +295,16 @@ function preLoadCss(cssUrl) {
292295 return ;
293296 }
294297 let searchLoaded = false ;
298+ // If you're browsing the nightly docs, the page might need to be refreshed for the
299+ // search to work because the hash of the JS scripts might have changed.
300+ function sendSearchForm ( ) {
301+ document . getElementsByClassName ( "search-form" ) [ 0 ] . submit ( ) ;
302+ }
295303 function loadSearch ( ) {
296304 if ( ! searchLoaded ) {
297305 searchLoaded = true ;
298- loadScript ( getVar ( "static-root-path" ) + getVar ( "search-js" ) ) ;
299- loadScript ( resourcePath ( "search-index" , ".js" ) ) ;
306+ loadScript ( getVar ( "static-root-path" ) + getVar ( "search-js" ) , sendSearchForm ) ;
307+ loadScript ( resourcePath ( "search-index" , ".js" ) , sendSearchForm ) ;
300308 }
301309 }
302310
You can’t perform that action at this time.
0 commit comments