aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/z-component.js
blob: e9b63ffb9243434e4ba041b3069b832f70540bb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
customElements.define(
	"z-component",
	class extends HTMLElement {
		constructor() {
			super();
			this.attachShadow({ mode: 'open' })
		}

		connectedCallback() {
			const type = this.getAttribute('type');
			const template = document.getElementById(`--${type}`);
			const node = document.importNode(template.content, true);
			this.shadowRoot.id = 'root';
			this.shadowRoot.appendChild(node);
		}
	}
);