From 2a3582e92551f40c11b8ef50cf0ba3d2bf5cb503 Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Thu, 10 Jul 2014 13:39:10 -0700 Subject: [PATCH] [changed] make URLStore.push idempotent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- modules/stores/URLStore.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/stores/URLStore.js b/modules/stores/URLStore.js index 5e740d45d0..6cb3550d99 100644 --- a/modules/stores/URLStore.js +++ b/modules/stores/URLStore.js @@ -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();