wcb/WebComponent.mjs
2023-09-17 01:36:58 +02:00

29 lines
545 B
JavaScript

// @ts-check
export class WebComponent extends HTMLElement {
get template() {
return "";
}
/**
* triggered when an attribute value changed
*/
onChanges({ previousValue, currentValue }) {}
connectedCallback() {
this.render();
}
attributeChangedCallback(property, previousValue, currentValue) {
if (previousValue !== currentValue) {
this[property] = currentValue;
this.render();
}
this.onChanges({ previousValue, currentValue });
}
render() {
this.innerHTML = this.template;
}
}