wcb/demo/HelloWorld.mjs
2023-09-17 02:09:02 +02:00

22 lines
528 B
JavaScript

// @ts-check
import WebComponent from "../index.mjs";
export class HelloWorld extends WebComponent {
name = "World";
emotion = "excited";
static get observedAttributes() {
return ["name", "emotion"];
}
onChanges({ property, previousValue, currentValue }) {
console.log(">>> changed", { property, previousValue, currentValue });
}
get template() {
return `
<h1>Hello ${this.name}${this.emotion === "sad" ? ". 😭" : "! 🙌"}</h1>`;
}
}
customElements.define("hello-world", HelloWorld);