You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
447 B
JavaScript
20 lines
447 B
JavaScript
|
3 years ago
|
export class Layout extends HTMLElement {
|
||
|
|
constructor() {
|
||
|
|
super()
|
||
|
|
this.attachShadow({mode: 'open'})
|
||
|
|
this.load()
|
||
|
|
addEventListener('hashchange', () => {
|
||
|
|
this.load()
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
load() {
|
||
|
|
const el = document.createElement('m-project')
|
||
|
|
const path = new URL(
|
||
|
|
window.location.hash.slice(1) || '/',
|
||
|
|
window.location
|
||
|
|
).pathname
|
||
|
|
el.setAttribute('path', path)
|
||
|
|
this.shadowRoot.replaceChildren(el)
|
||
|
|
}
|
||
|
|
}
|