diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2016-03-19 12:30:00 +0200 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2016-03-19 12:30:00 +0200 |
| commit | 5a5b5f1e9f50be73dca38aafb7abeddfed1fcab6 (patch) | |
| tree | ae05aa8802b854d2919c87fb8c60acb755de9fa6 | |
| parent | 33c28b45c8bf22ce3ee4fac0446bfd86fbf4f0ef (diff) | |
| parent | 2910c0020661304df237fb8ed646296304c8e0d2 (diff) | |
| download | rust-5a5b5f1e9f50be73dca38aafb7abeddfed1fcab6.tar.gz rust-5a5b5f1e9f50be73dca38aafb7abeddfed1fcab6.zip | |
Rollup merge of #32308 - bombless:patch-2, r=alexcrichton
Fix usability problem when browse document locally You cannot use `history.replaceState` when you browse locally, it breaks the security policy of Chrome and perhaps other browsers. Closes https://github.com/rust-lang/rust/issues/32307 Thank @crumblingstatue for the help!
| -rw-r--r-- | src/librustdoc/html/static/main.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index f3efbcb1db3..8fb58f58e8a 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -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="); + } $('#main.content').removeClass('hidden'); $('#search.content').addClass('hidden'); } else { @@ -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 { |
