...
 
Commits (3)
......@@ -67,7 +67,7 @@ export default class SIBRoute extends HTMLElement {
router.display();
}
}
activate() {
activate(keepURL=false) {
if (
'HTMLDialogElement' in window &&
this.view instanceof window.HTMLDialogElement
......@@ -80,7 +80,7 @@ export default class SIBRoute extends HTMLElement {
}
this.setAttribute('active', '');
this.updateResource();
this.updateSubRouters();
if (!keepURL) this.updateSubRouters();
}
hide() {
if (
......
......@@ -38,7 +38,7 @@ export default class SIBRouter extends HTMLElement {
return this.querySelectorAll('sib-route');
}
display(routeName = this.currentRouteName, resource) {
display(routeName = this.currentRouteName, resource, keepURL=false) {
for (let route of this.routes) {
if (routeName === route.name) {
this.dispatchEvent(
......@@ -46,13 +46,13 @@ export default class SIBRouter extends HTMLElement {
detail: { route: routeName, resource },
}),
);
route.activate();
route.activate(keepURL);
} else {
route.hide();
}
}
}
navigate(routeName = '', resource, keepURL) {
navigate(routeName = '', resource, keepURL=this.hasAttribute('keep-url')) {
let route;
if (routeName) {
route = this.querySelector('sib-route[name="' + routeName + '"]');
......@@ -77,12 +77,12 @@ export default class SIBRouter extends HTMLElement {
}
const id = resource ? resource['@id'] : null;
const path = route.getPath(this.prefix, routeName, id);
if (!keepURL && !this.hasAttribute('keep-url')) {
if (!keepURL) {
//update current URL
const prefix = this.useHash ? '#' : '/';
history.pushState({}, routeName, prefix + path);
}
this.display(routeName, resource);
this.display(routeName, resource, keepURL);
}
}
customElements.define('sib-router', SIBRouter);
......