diff --git a/templates/basic/src/components/vanilla-hello-world.js b/templates/basic/src/components/vanilla-hello-world.js index 3632152..69f69c3 100644 --- a/templates/basic/src/components/vanilla-hello-world.js +++ b/templates/basic/src/components/vanilla-hello-world.js @@ -1,20 +1,21 @@ class HelloWorld extends HTMLElement { static get observedAttributes() { - return ["data-name"]; + return ["my-name"]; } connectedCallback() { let count = 0; - - if (!('name' in this.dataset)) { - this.dataset.name = 'World'; + const currentName = this.getAttribute('my-name'); + + if (!currentName) { + this.setAttribute('my-name', 'World') } - this.onclick = () => this.dataset.name = `Clicked ${++count}x`; + this.onclick = () => this.setAttribute("my-name", `Clicked ${++count}x`); } attributeChangedCallback(property, previousValue, currentValue) { - if (property === "data-name" && previousValue !== currentValue) { + if (property === "my-name" && previousValue !== currentValue) { this.innerHTML = ``; } }