class StatBlock extends HTMLElement { static get observedAttributes() { return ['title', 'value']; } constructor() { super(); this.attachShadow({ mode: 'open' }); this.render(); } attributeChangedCallback(name, oldValue, newValue) { this.render(); // Re-render whenever an attribute changes } render() { const title = this.getAttribute('title') || ''; const value = this.getAttribute('value') || ''; this.shadowRoot.innerHTML = `
${title}
${value}
`; } } customElements.define('stat-block', StatBlock);