class CustomTestimonial extends HTMLElement { static get observedAttributes() { return ['name', 'title', 'text', 'photo']; } constructor() { super(); this.attachShadow({ mode: 'open' }); } connectedCallback() { this.render(); } attributeChangedCallback(name, oldValue, newValue) { if (oldValue !== newValue) { this.render(); } } render() { const name = this.getAttribute('name') || ''; const title = this.getAttribute('title') || ''; const text = this.getAttribute('text') || ''; const photo = this.getAttribute('photo') || 'http://static.photos/people/200x200/10'; this.shadowRoot.innerHTML = `
${text}
${name}
${name} ${title}
`; } } customElements.define('custom-testimonial', CustomTestimonial);