Commit 5bd3e541 authored by Clément's avatar Clément

fix view getter

parent e6e104de
......@@ -2,8 +2,7 @@
(function(){
class SIBRoute extends HTMLElement {
constructor() {
super()
this.name = this.name;
super();
}
connectedCallback() {
this.addEventListener('click', event => this.router.navigate(this.name));
......@@ -14,10 +13,17 @@
}
set name(name) {
this.setAttribute('name', name);
this.view = document.getElementById(this.name);
if(!this.view) {
}
get view(){
const view = document.getElementById(this.name);
if(!view) {
throw new Error(`view "#${this.name}" is not in document`);
}
this.view = view;
return view;
}
set view(value) {
Object.defineProperty(this, 'view', {value});
}
get router() {
return this.closest('sib-router');
......@@ -47,7 +53,7 @@
router.display();
}
activate() {
this.view.removeAttribute('hidden')
this.view.removeAttribute('hidden');
this.setAttribute('active', '');
this.updateResource();
......
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