class Counter extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: "open" });
const text = this.shadowRoot.appendChild(document.createElement("p"));
const button = this.shadowRoot.appendChild(document.createElement("button"));
text.textContent = 0;
button.textContent = "add";
button.addEventListener("click", () => {
text.textContent = Number(text.textContent) + 1;
});
}
}
customElements.define("number-counter", Counter);