Skip to content

Commit e7c4628

Browse files
Rollup merge of rust-lang#41950 - GuillaumeGomez:rustdoc-links, r=frewsxcv
Fix anchor invalid redirection to search Fixes rust-lang#41933. r? @rust-lang/docs
2 parents 38ccafc + b09a19b commit e7c4628

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/librustdoc/html/static/main.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -943,9 +943,9 @@
943943
if (hasClass(main, 'content')) {
944944
removeClass(main, 'hidden');
945945
}
946-
var search = document.getElementById('search');
947-
if (hasClass(main, 'content')) {
948-
addClass(main, 'hidden');
946+
var search_c = document.getElementById('search');
947+
if (hasClass(search_c, 'content')) {
948+
addClass(search_c, 'hidden');
949949
}
950950
}
951951
// Revert to the previous title manually since the History
@@ -959,7 +959,11 @@
959959
// perform the search. This will empty the bar if there's
960960
// nothing there, which lets you really go back to a
961961
// previous state with nothing in the bar.
962-
document.getElementsByClassName('search-input')[0].value = params.search;
962+
if (params.search) {
963+
document.getElementsByClassName('search-input')[0].value = params.search;
964+
} else {
965+
document.getElementsByClassName('search-input')[0].value = '';
966+
}
963967
// Some browsers fire 'onpopstate' for every page load
964968
// (Chrome), while others fire the event only when actually
965969
// popping a state (Firefox), which is why search() is

0 commit comments

Comments
 (0)