diff --git a/src/components/my-hello-world.js b/src/components/my-hello-world.js index dc2ab43..d2efed6 100644 --- a/src/components/my-hello-world.js +++ b/src/components/my-hello-world.js @@ -1,15 +1,15 @@ class HelloWorld extends WebComponent { - static properties = ["name"]; + static properties = ["data-name"]; onInit() { let count = 0; this.onclick = () => { - this.setAttribute("name", `Clicked ${++count}x`); + this.setAttribute("data-name", `Clicked ${++count}x`); }; this.setAttribute("title", "Click me please"); } get template() { - return ``; + return ``; } } diff --git a/src/components/vanilla-hello-world.js b/src/components/vanilla-hello-world.js index d0e0e23..12a1564 100644 --- a/src/components/vanilla-hello-world.js +++ b/src/components/vanilla-hello-world.js @@ -1,17 +1,17 @@ class HelloWorld extends HTMLElement { static get observedAttributes() { - return ["name"]; + return ["data-name"]; } connectedCallback() { let count = 0; this.onclick = () => { - this.setAttribute("name", `Clicked ${++count}x`); + this.setAttribute("data-name", `Clicked ${++count}x`); }; } attributeChangedCallback(property, previousValue, currentValue) { - if (previousValue !== currentValue) { + if (property === "data-name" && previousValue !== currentValue) { this.innerHTML = ``; } } diff --git a/src/pages/demo/index.html b/src/pages/demo/index.html index 99ec905..e767139 100644 --- a/src/pages/demo/index.html +++ b/src/pages/demo/index.html @@ -46,7 +46,7 @@
some text: {{greeting}}
diff --git a/src/pages/index.html b/src/pages/index.html index 232bec2..8d4db5b 100644 --- a/src/pages/index.html +++ b/src/pages/index.html @@ -31,7 +31,7 @@
Here's a sample interactive custom element:
-
Start at the very basic of writing HTML files and enhance with