diff --git a/ignite-router.js b/ignite-router.js index 136ce17..6ad1f4e 100644 --- a/ignite-router.js +++ b/ignite-router.js @@ -43,13 +43,13 @@ class RouterLink extends IgniteElement { } update() { - var routeMatches = true; + var routeMatches = false; //Check the target first. routeMatches = RouteMatcher.matches(this.target); //Check optional routes next. - for (var i = 0; i < this.routes.length && routeMatches; i++) { + for (var i = 0; i < this.routes.length && !routeMatches; i++) { routeMatches = RouteMatcher.matches(this.routes[i]); } @@ -101,12 +101,14 @@ class RouterView extends IgniteElement { } update() { - var routeMatches = true; + var routeMatches = false; - for (var i = 0; i < this.routes.length && routeMatches; i++) { + //Check all of the possible routes until we find a match. + for (var i = 0; i < this.routes.length && !routeMatches; i++) { routeMatches = RouteMatcher.matches(this.routes[i]); } + //If we found a match show this router view if it's not already visible, otherwise hide it. if (routeMatches && !this.show) { this.show = true; } else if (!routeMatches && this.show) {