Permalink
Browse files

LocationRouter start now clears the previous history

  • Loading branch information...
podefr committed Sep 2, 2013
1 parent 401ee7f commit a293fa81ce30135f7df5ce703a1da2e7faeb937a
Showing with 9 additions and 0 deletions.
  1. +8 −0 specs/LocationRouter.spec.js
  2. +1 −0 src/LocationRouter.js
@@ -123,6 +123,14 @@ require(["LocationRouter", "Router"], function (LocationRouter, Router) {
expect(window.location.hash).toBe("#hello/im/the/router");
});
+ it("clears the previous history on start so the route coming from the url is the initial one", function () {
+ spyOn(locationRouter, "clearHistory");
+
+ locationRouter.start();
+
+ expect(locationRouter.clearHistory).toHaveBeenCalled();
+ });
+
});
describe("LocationRouter can be destroyed", function () {
View
@@ -60,6 +60,7 @@ function LocationRouter(Router, Tools) {
* While navigating, the hashmark itself will also change to reflect the current route state
*/
this.start = function start() {
+ this.clearHistory();
var parsedHash = this.parse(window.location.hash);
this.navigate.apply(this, parsedHash);
this.bindOnHashChange();

0 comments on commit a293fa8

Please sign in to comment.