Skip to content

Commit

Permalink
fix history on programmatic path updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane Gibbons committed Jan 24, 2019
1 parent 8c7f4f5 commit 97b4e8b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/_docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Searches for a matching path, and if it finds one, runs the associated handlers.
* `path` — string — The path to which to navigate.
* `handler` — object — (Optional) An additional handler to run after the standard handler.

### `prettify(path, title)`
### `prettify(path, title, state =`

Updates the path and, optionally, the title of the page without firing any handlers. This will be a purely aesthetic update to the location, and won't affect navigation / history.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "air-traffic-control",
"version": "0.1.1",
"version": "0.1.2",
"description": "Dead simple redux routing",
"main": "build/air-traffic-control.js",
"scripts": {
Expand Down
11 changes: 2 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,8 @@ export class Router {
* @param {string} title - (Optional) The new title.
*
*/
prettify(path, title) { // eslint-disable-line class-methods-use-this
window.history.replaceState(
{
pretty: true,
orginalPath: window.location.pathname,
},
title,
path,
);
prettify(path, title, state = {}) { // eslint-disable-line class-methods-use-this
window.history.pushState(state, title, path);
if (title) {
document.title = title;
}
Expand Down

0 comments on commit 97b4e8b

Please sign in to comment.