File tree 1 file changed +11
-3
lines changed
src/librustdoc/html/static/js
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -185,9 +185,12 @@ function preLoadCss(cssUrl) {
185
185
( function ( ) {
186
186
const isHelpPage = window . location . pathname . endsWith ( "/help.html" ) ;
187
187
188
- function loadScript ( url ) {
188
+ function loadScript ( url , errorCallback ) {
189
189
const script = document . createElement ( "script" ) ;
190
190
script . src = url ;
191
+ if ( errorCallback !== undefined ) {
192
+ script . onerror = errorCallback ;
193
+ }
191
194
document . head . append ( script ) ;
192
195
}
193
196
@@ -292,11 +295,16 @@ function preLoadCss(cssUrl) {
292
295
return ;
293
296
}
294
297
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
+ }
295
303
function loadSearch ( ) {
296
304
if ( ! searchLoaded ) {
297
305
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 ) ;
300
308
}
301
309
}
302
310
You can’t perform that action at this time.
0 commit comments