Skip to content

Commit

Permalink
[changed] make URLStore.push idempotent
Browse files Browse the repository at this point in the history
If somebody’s component is observing some user
input its easy to start pushing the same url
into the store, this makes it so devs can kind
of treat `Router.transitionTo` like rendering,
nothing happens if nothing has changed.

Previously, you get a bunch of history entries
that don’t change UI as the user clicks the back
button.

closes #79
  • Loading branch information
KyleAMathews authored and ryanflorence committed Jul 27, 2014
1 parent 97c02f1 commit 2a3582e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/stores/URLStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ var URLStore = {
* Pushes the given path onto the browser navigation stack.
*/
push: function (path) {
if (path === _currentPath)
return;

if (_location === 'history') {
window.history.pushState({ path: path }, '', path);
notifyChange();
Expand Down

0 comments on commit 2a3582e

Please sign in to comment.