iportal
Version:
web-portal
44 lines (40 loc) • 1.05 kB
text/typescript
import '../shim/native-shim'
export class Runaway extends HTMLElement {
constructor () {
super()
this.style.cssText = `
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
inset: 0;
width: 100%;
height: 100%;
`
const tmpl = document.createElement('template')
tmpl.innerHTML = `
<slot name="module"></slot>
`
const shadowRoot = this.attachShadow({ mode: 'open' })
shadowRoot.appendChild(tmpl.content.cloneNode(true))
}
connectedCallback () {
const id = this.id
if (id) {
if (!window.__application_preset) {
window.__application_preset = {
modules: {}
}
} else if (!window.__application_preset.modules) {
window.__application_preset.modules = {}
}
if (window.__application_preset.modules) {
window.__application_preset.modules[id] = this
}
} else {
console.error('<run-away> required parameter id is missing!')
}
}
}
customElements.define('run-away', Runaway)