From 7456e3cc6da62414f6845e5f8b1a606cd8a1acfb Mon Sep 17 00:00:00 2001 From: sundowndev Date: Tue, 14 May 2019 14:05:38 +0200 Subject: [PATCH] refactor: reset previously matched route on hash change --- src/leafeon.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/leafeon.ts b/src/leafeon.ts index 2cf71b6..9f393b2 100644 --- a/src/leafeon.ts +++ b/src/leafeon.ts @@ -103,13 +103,13 @@ export class Router extends RouterRequest { this.notfound = true; // While a route has not match the URI, set page as not found this.routes = []; this.paramsEnabled = false; + this.route = null; this.params = []; this.beforeRouteMiddleware = '*'; - this.routeCall = () => {}; - this.beforeRouteMiddlewareFunc = () => {}; - this.afterRouteCallback = () => {}; - this.route = {}; - this.notFoundCallback = () => {}; + this.routeCall = null; + this.beforeRouteMiddlewareFunc = null; + this.afterRouteCallback = null; + this.notFoundCallback = null; this.windowListener(this.run); } @@ -314,6 +314,11 @@ export class Router extends RouterRequest { * @param afterRouteCallback */ public run = (afterRouteCallback?: any): void => { + this.route = null; + this.routeCall = null; + this.params = []; + this.notfound = true; + const URI = this.getURI(); const routes: Array = [];