Skip to content

Commit 2910c00

Browse files
committed
Fix usability problem when browse document locally
1 parent abb1515 commit 2910c00

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/librustdoc/html/static/main.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,11 @@
740740
$(".search-input").on("keyup input",function() {
741741
clearTimeout(searchTimeout);
742742
if ($(this).val().length === 0) {
743-
window.history.replaceState("", "std - Rust", "?search=");
743+
if (browserSupportsHistoryApi()) {
744+
history.replaceState("", "std - Rust", "?search=");
745+
} else {
746+
location.replace("?search=");
747+
}
744748
$('#main.content').removeClass('hidden');
745749
$('#search.content').addClass('hidden');
746750
} else {
@@ -996,7 +1000,7 @@
9961000
var prev_id = 0;
9971001

9981002
function set_fragment(name) {
999-
if (history.replaceState) {
1003+
if (browserSupportsHistoryApi()) {
10001004
history.replaceState(null, null, '#' + name);
10011005
$(window).trigger('hashchange');
10021006
} else {

0 commit comments

Comments
 (0)