Commit 8dba84d0 authored by Clément's avatar Clément

Merge branch 'fix/resource-undefined' into 'master'

bugfix: resource is now defined as well on DOMContentLoaded

See merge request !19
parents c358adef 85e5b3c4
Pipeline #2823 passed with stage
in 32 seconds
...@@ -38,13 +38,13 @@ export default class SIBRouter extends HTMLElement { ...@@ -38,13 +38,13 @@ export default class SIBRouter extends HTMLElement {
return this.querySelectorAll('sib-route'); return this.querySelectorAll('sib-route');
} }
display(routeName = this.currentRouteName, resource, keepURL=false) { display(routeName = this.currentRouteName, keepURL=false) {
for (let route of this.routes) { for (let route of this.routes) {
if (routeName === route.name) { if (routeName === route.name) {
route.activate(keepURL); route.activate(keepURL);
this.dispatchEvent( this.dispatchEvent(
new CustomEvent('navigate', { new CustomEvent('navigate', {
detail: { route: routeName, resource }, detail: { route: routeName, resource: {id: route.resourceId} },
}), }),
); );
} else { } else {
...@@ -82,7 +82,7 @@ export default class SIBRouter extends HTMLElement { ...@@ -82,7 +82,7 @@ export default class SIBRouter extends HTMLElement {
const prefix = this.useHash ? '#' : '/'; const prefix = this.useHash ? '#' : '/';
history.pushState({}, routeName, prefix + path); history.pushState({}, routeName, prefix + path);
} }
this.display(routeName, resource, keepURL); this.display(routeName, keepURL);
} }
} }
customElements.define('sib-router', SIBRouter); customElements.define('sib-router', SIBRouter);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment