feat: update code example

This commit is contained in:
Ayo 2023-12-21 18:06:34 +01:00
parent 55c83e6d86
commit 4259ea51cd

View file

@ -32,7 +32,7 @@ Let's consider the following code example (also [in CodePen →](https://code
class Counter extends HTMLElement { class Counter extends HTMLElement {
static observedAttributes = ["data-count"]; static observedAttributes = ["data-count"];
connectedCallback() { connectedCallback() {
this.dataset.count = this.getAttribute('data-count') ?? 0; this.dataset.count = 0;
this.onclick = () => ++this.dataset.count; this.onclick = () => ++this.dataset.count;
} }
attributeChangedCallback(prop, oldValue, newValue) { attributeChangedCallback(prop, oldValue, newValue) {