diff --git a/bower.json b/bower.json index a31ef967..6e0ea81f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "aurelia-router", - "version": "0.5.3", + "version": "0.5.4", "description": "A powerful client-side router.", "keywords": [ "aurelia", diff --git a/dist/amd/app-router.js b/dist/amd/app-router.js index cc50d728..fcb5d3af 100644 --- a/dist/amd/app-router.js +++ b/dist/amd/app-router.js @@ -90,8 +90,8 @@ define(["exports", "aurelia-dependency-injection", "aurelia-history", "./router" if (isNavigationCommand(result.output)) { result.output.navigate(_this); - } else if (!result.completed && _this.history.previousFragment) { - _this.navigate(_this.history.previousFragment, false); + } else if (!result.completed) { + _this.navigate(_this.history.previousFragment || "", false); } instruction.resolve(result); @@ -161,13 +161,20 @@ define(["exports", "aurelia-dependency-injection", "aurelia-history", "./router" })(Router); + function findAnchor(el) { + while (el) { + if (el.tagName === "A") return el; + el = el.parentNode; + } + } + function handleLinkClick(evt) { if (!this.isActive) { return; } - var target = evt.target; - if (target.tagName != "A") { + var target = findAnchor(evt.target); + if (!target) { return; } diff --git a/dist/amd/router.js b/dist/amd/router.js index 9061f6b6..0cd5b4ce 100644 --- a/dist/amd/router.js +++ b/dist/amd/router.js @@ -82,6 +82,7 @@ define(["exports", "aurelia-route-recognizer", "aurelia-path", "./navigation-con navigate: { value: function navigate(fragment, options) { fragment = join(this.baseUrl, fragment); + if (fragment === "") fragment = "/"; return this.history.navigate(fragment, options); }, writable: true, diff --git a/dist/commonjs/app-router.js b/dist/commonjs/app-router.js index 695e878e..91bebba5 100644 --- a/dist/commonjs/app-router.js +++ b/dist/commonjs/app-router.js @@ -89,8 +89,8 @@ var AppRouter = exports.AppRouter = (function (Router) { if (isNavigationCommand(result.output)) { result.output.navigate(_this); - } else if (!result.completed && _this.history.previousFragment) { - _this.navigate(_this.history.previousFragment, false); + } else if (!result.completed) { + _this.navigate(_this.history.previousFragment || "", false); } instruction.resolve(result); @@ -160,13 +160,20 @@ var AppRouter = exports.AppRouter = (function (Router) { })(Router); +function findAnchor(el) { + while (el) { + if (el.tagName === "A") return el; + el = el.parentNode; + } +} + function handleLinkClick(evt) { if (!this.isActive) { return; } - var target = evt.target; - if (target.tagName != "A") { + var target = findAnchor(evt.target); + if (!target) { return; } diff --git a/dist/commonjs/router.js b/dist/commonjs/router.js index 2d9d4852..3c84b9c4 100644 --- a/dist/commonjs/router.js +++ b/dist/commonjs/router.js @@ -81,6 +81,7 @@ var Router = exports.Router = (function () { navigate: { value: function navigate(fragment, options) { fragment = join(this.baseUrl, fragment); + if (fragment === "") fragment = "/"; return this.history.navigate(fragment, options); }, writable: true, diff --git a/dist/es6/app-router.js b/dist/es6/app-router.js index b026f1c1..820d815f 100644 --- a/dist/es6/app-router.js +++ b/dist/es6/app-router.js @@ -62,8 +62,8 @@ export class AppRouter extends Router { if (isNavigationCommand(result.output)) { result.output.navigate(this); - } else if (!result.completed && this.history.previousFragment) { - this.navigate(this.history.previousFragment, false); + } else if (!result.completed) { + this.navigate(this.history.previousFragment || '', false); } instruction.resolve(result); @@ -111,13 +111,20 @@ export class AppRouter extends Router { } } +function findAnchor(el) { + while (el) { + if (el.tagName === "A") return el; + el = el.parentNode; + } +} + function handleLinkClick(evt) { if (!this.isActive) { return; } - var target = evt.target; - if (target.tagName != 'A') { + var target = findAnchor(evt.target); + if (!target) { return; } diff --git a/dist/es6/router.js b/dist/es6/router.js index 22ecbfef..9e194fa7 100644 --- a/dist/es6/router.js +++ b/dist/es6/router.js @@ -64,6 +64,7 @@ export class Router { navigate(fragment, options) { fragment = join(this.baseUrl, fragment); + if(fragment === '') fragment = '/'; return this.history.navigate(fragment, options); } diff --git a/dist/system/app-router.js b/dist/system/app-router.js index 7b5d9dd3..effcb340 100644 --- a/dist/system/app-router.js +++ b/dist/system/app-router.js @@ -4,13 +4,20 @@ System.register(["aurelia-dependency-injection", "aurelia-history", "./router", var Container, History, Router, PipelineProvider, isNavigationCommand, _prototypeProperties, _get, _inherits, AppRouter; + function findAnchor(el) { + while (el) { + if (el.tagName === "A") return el; + el = el.parentNode; + } + } + function handleLinkClick(evt) { if (!this.isActive) { return; } - var target = evt.target; - if (target.tagName != "A") { + var target = findAnchor(evt.target); + if (!target) { return; } @@ -128,8 +135,8 @@ System.register(["aurelia-dependency-injection", "aurelia-history", "./router", if (isNavigationCommand(result.output)) { result.output.navigate(_this); - } else if (!result.completed && _this.history.previousFragment) { - _this.navigate(_this.history.previousFragment, false); + } else if (!result.completed) { + _this.navigate(_this.history.previousFragment || "", false); } instruction.resolve(result); diff --git a/dist/system/router.js b/dist/system/router.js index ca14d41d..36286f49 100644 --- a/dist/system/router.js +++ b/dist/system/router.js @@ -92,6 +92,7 @@ System.register(["aurelia-route-recognizer", "aurelia-path", "./navigation-conte navigate: { value: function navigate(fragment, options) { fragment = join(this.baseUrl, fragment); + if (fragment === "") fragment = "/"; return this.history.navigate(fragment, options); }, writable: true, diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 3936abf9..310633ae 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,3 +1,13 @@ +### 0.5.4 (2015-02-03) + + +#### Bug Fixes + +* **router:** + * canActivate = false doesn't change back route ([80b219cc](http://github.com/aurelia/router/commit/80b219cc81c5e3d0c82dc35745aafcd2910f9214)) + * link click handler not triggering when clicking on a nested element inside an an ([a08ee477](http://github.com/aurelia/router/commit/a08ee477177773fee0e6845b0eeb183cd238793c)) + + ### 0.5.3 (2015-01-30) diff --git a/package.json b/package.json index 95a91c62..dec8dc17 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-router", - "version": "0.5.3", + "version": "0.5.4", "description": "A powerful client-side router.", "keywords": [ "aurelia",