only navigate when a change has been detected

This commit is contained in:
Niels Lyngsø
2024-06-28 10:11:14 +02:00
parent 3dba4abb32
commit cb1f5e1249

View File

@@ -201,11 +201,8 @@ export class RouterSlot<D = any, P = any> extends HTMLElement implements IRouter
navigate = this._routeMatch === null;
if (navigate === false) {
const newMatch = this.getRouteMatch();
console.log("new match...", newMatch)
// Check if match is still present? [NL]
// Check if there is a better/different match? [NL]
// Maybe both are handled in this approach? [NL]
navigate = this._routeMatch !== newMatch;
// Check if this match matches the current match (aka. If the path has changed), if so we should navigate. [NL]
navigate = this._routeMatch?.route.path !== newMatch?.route.path;
}
}
@@ -214,7 +211,6 @@ export class RouterSlot<D = any, P = any> extends HTMLElement implements IRouter
// Register that the path has changed so the correct route can be loaded.
if (navigate) {
console.log("navigate...")
this.render();
}
}