diff --git a/site/src/components/my-hello-world.js b/site/src/components/my-hello-world.js index d9d01c6..3f1b822 100644 --- a/site/src/components/my-hello-world.js +++ b/site/src/components/my-hello-world.js @@ -3,15 +3,16 @@ * @see https://ayco.io/n/web-component-base */ class HelloWorld extends WebComponent { + dataName = 'World'; + static properties = ["data-name"]; onInit() { let count = 0; - this.dataset.name = this.dataset.name ?? 'World'; this.onclick = () => this.dataset.name = `Clicked ${++count}x`; } get template() { - return ``; + return ``; } } diff --git a/site/src/components/vanilla-hello-world.js b/site/src/components/vanilla-hello-world.js index e2cea68..262dea7 100644 --- a/site/src/components/vanilla-hello-world.js +++ b/site/src/components/vanilla-hello-world.js @@ -5,7 +5,11 @@ class HelloWorld extends HTMLElement { connectedCallback() { let count = 0; - this.dataset.name = this.dataset.name ?? 'World'; + + if (!('name' in this.dataset)) { + this.dataset.name = 'World' + } + this.onclick = () => this.dataset.name = `Clicked ${++count}x`; } diff --git a/site/src/pages/index.html b/site/src/pages/index.html index f95dea7..d7fb641 100644 --- a/site/src/pages/index.html +++ b/site/src/pages/index.html @@ -33,8 +33,7 @@

npm create mcfly@latest

- Here's a sample interactive custom element: - + Here's a sample interactive custom element:

Start at the very basic of writing HTML files and enhance with