Updates to run inside or outside sandbox

file-group-page
bat 3 years ago
parent cf474e7f50
commit 40f1a49e6e

@ -36,6 +36,9 @@ export class Layout extends HTMLElement {
addEventListener('hashchange', () => {
this.load()
})
this.addEventListener('hash-change', () => {
this.load()
})
}
load() {

@ -42,16 +42,17 @@ export class NavMenu extends HTMLElement {
this.shadowRoot.append(this.pageList)
this.renderPageList()
this.shadowRoot.addEventListener('click', e => {
if (this.handleLinks) {
e.preventDefault()
}
if (e.target.classList.contains('page')) {
if (this.handleLinks) {
e.preventDefault()
}
this.dispatchEvent(new CustomEvent(
'close-menu', {bubbles: true}
))
}
if (this.handleLinks) {
location.hash = `#${e.target.innerText}`
if (this.handleLinks) {
const hash = '#' + e.target.innerText
location.hash = hash
}
}
})
}

@ -131,7 +131,7 @@ export class Page extends HTMLElement {
}
display(value) {
let doc = value
let doc = value || ''
if (!(/<\w/).test(doc.substring(0, 30))) {
doc = `<pre style="white-space: pre-wrap; margin: 8px 12px; font-family: monospace;">` +
doc.replace("<", "&lt;").replace(">", "&gt;") +

Loading…
Cancel
Save