Skip to content

Commit

Permalink
fix: the exception in Safari due to too many calls to the history.rep…
Browse files Browse the repository at this point in the history
…lacestate method
  • Loading branch information
子奂 committed Mar 30, 2020
1 parent 3fd202f commit 2834372
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,3 @@ ReactDOM.render(<App />, document.getElementById('root'));
## 🍺 License

[MIT license](./LICENSE)

## ☕️ Donate me a coffee

<div style="overflow: hidden;">
<img style="display: inline-block;" width="auto" height="240" src="https://github.com/parksben/markdown-navbar/blob/master/assets/wechat.jpg?raw=true" alt="wechat" />
<img style="display: inline-block;" width="auto" height="240" src="https://github.com/parksben/markdown-navbar/blob/master/assets/alipay.jpg?raw=true" alt="alipay" />
</div>
Binary file removed assets/alipay.jpg
Binary file not shown.
Binary file removed assets/wechat.jpg
Binary file not shown.
16 changes: 11 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,17 @@ export class MarkdownNavbar extends Component {
};

updateHash(value) {
window.history.replaceState(
{},
'',
`${window.location.pathname}${window.location.search}#${value}`
);
if (this.updateHashTimeout) {
clearTimeout(this.updateHashTimeout);
}

this.updateHashTimeout = setTimeout(() => {
window.history.replaceState(
{},
'',
`${window.location.pathname}${window.location.search}#${value}`
);
}, 0);
}

render() {
Expand Down

0 comments on commit 2834372

Please sign in to comment.