Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix usability problem when browse document locally
  • Loading branch information
bombless committed Mar 17, 2016
1 parent abb1515 commit 2910c00
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/librustdoc/html/static/main.js
Expand Up @@ -740,7 +740,11 @@
$(".search-input").on("keyup input",function() {
clearTimeout(searchTimeout);
if ($(this).val().length === 0) {
window.history.replaceState("", "std - Rust", "?search=");
if (browserSupportsHistoryApi()) {
history.replaceState("", "std - Rust", "?search=");
} else {
location.replace("?search=");

This comment has been minimized.

Copy link
@xitep

xitep Mar 25, 2016

This causes the page to reload in FF (45) and Chrome and makes hitting 'S' basically useless :/

Since the searched string is anyway not appended to location.search after the search, I'd suggest we drop this else branch.

}
$('#main.content').removeClass('hidden');
$('#search.content').addClass('hidden');
} else {
Expand Down Expand Up @@ -996,7 +1000,7 @@
var prev_id = 0;

function set_fragment(name) {
if (history.replaceState) {
if (browserSupportsHistoryApi()) {
history.replaceState(null, null, '#' + name);
$(window).trigger('hashchange');
} else {
Expand Down

0 comments on commit 2910c00

Please sign in to comment.