diff --git a/_posts/2023-12-21-reactive-custom-elements-with-html-dataset.md b/_posts/2023-12-21-reactive-custom-elements-with-html-dataset.md index a152f39..67719d2 100644 --- a/_posts/2023-12-21-reactive-custom-elements-with-html-dataset.md +++ b/_posts/2023-12-21-reactive-custom-elements-with-html-dataset.md @@ -39,7 +39,7 @@ Let's consider the following code example (also [in CodePen →](https://code class Counter extends HTMLElement { static observedAttributes = ["data-count"]; connectedCallback() { - this.dataset.count = 0; + this.dataset.count = this.dataset.count ?? 0; this.onclick = () => ++this.dataset.count; } attributeChangedCallback(prop, oldValue, newValue) {