class ScoreDisplay extends HTMLElement { static get observedAttributes() { return ['score']; } constructor() { super(); this.attachShadow({ mode: 'open' }); this.score = 0; } connectedCallback() { this.render(); } attributeChangedCallback(name, oldValue, newValue) { if (name === 'score') { this.score = newValue; this.render(); } } render() { this.shadowRoot.innerHTML = `
${this.score}