Skip to content

rustdoc: Reset the title when pressing the back button #26732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,9 @@
// Push and pop states are used to add search results to the browser
// history.
if (browserSupportsHistoryApi()) {
// Store the previous <title> so we can revert back to it later.
var previousTitle = $(document).prop("title");

$(window).on('popstate', function(e) {
var params = getQueryStringParams();
// When browsing back from search results the main page
Expand All @@ -705,6 +708,9 @@
$('#main.content').removeClass('hidden');
$('#search.content').addClass('hidden');
}
// Revert to the previous title manually since the History
// API ignores the title parameter.
$(document).prop("title", previousTitle);
// When browsing forward to search results the previous
// search will be repeated, so the currentResults are
// cleared to ensure the search is successful.
Expand Down