Closed lukaszpolowczyk closed 6 years ago
class Counter extends HTMLElement { #xValue = 0; get #x() { return #xValue; } set #x(value) { #xValue = value; window.requestAnimationFrame(#render.bind(this)); } #clicked() { #x++; } constructor() { super(); onclick = #clicked.bind(this); } connectedCallback() { #render(); } #render() { textContent = #x.toString(); } } window.customElements.define('num-counter', Counter);
Note, this short form is proposed in https://github.com/littledan/proposal-private-shorthand
Let's continue considering the private shorthand in its own repository.