Skip to content

Commit 36882a0

Browse files
committed
rustdoc: Reset the title when pressing the back button
Fixes #26673
1 parent d2cf9f9 commit 36882a0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/librustdoc/html/static/main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,9 @@
697697
// Push and pop states are used to add search results to the browser
698698
// history.
699699
if (browserSupportsHistoryApi()) {
700+
// Store the previous <title> so we can revert back to it later.
701+
var previousTitle = $(document).prop("title");
702+
700703
$(window).on('popstate', function(e) {
701704
var params = getQueryStringParams();
702705
// When browsing back from search results the main page
@@ -705,6 +708,9 @@
705708
$('#main.content').removeClass('hidden');
706709
$('#search.content').addClass('hidden');
707710
}
711+
// Revert to the previous title manually since the History
712+
// API ignores the title parameter.
713+
$(document).prop("title", previousTitle);
708714
// When browsing forward to search results the previous
709715
// search will be repeated, so the currentResults are
710716
// cleared to ensure the search is successful.

0 commit comments

Comments
 (0)