From acd5e3e93333e4e4a40a8c6d13873c2b3b3f1ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdo=CC=81n=20Rodri=CC=81guez=20Davila?= Date: Wed, 14 Oct 2020 11:53:01 +0200 Subject: [PATCH] Skip router render meanwhile there is no outlet --- src/router/index.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index 03594c07..98916ea5 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -12,20 +12,24 @@ import { routes } from './routes.js'; const router = new Router(); -router.setRoutes([ - // Redirect to URL without trailing slash - { - path: '(.*)/', - action: (context, commands) => { - const newPath = context.pathname.slice(0, -1); - return commands.redirect(newPath); +router.setRoutes( + [ + // Redirect to URL without trailing slash + { + path: '(.*)/', + action: (context, commands) => { + const newPath = context.pathname.slice(0, -1); + return commands.redirect(newPath); + }, }, - }, - ...routes, -]); + ...routes, + ], + true +); export const attachRouter = (outlet: HTMLElement) => { router.setOutlet(outlet); + router.render(window.location, true); }; export const urlForName = (name: string, params?: Params) => {