class ProductCard extends HTMLElement {
connectedCallback() {
const name = this.getAttribute('name') || 'Product';
const price = parseFloat(this.getAttribute('price')) || 0;
const image = this.getAttribute('image') || '';
const rating = parseFloat(this.getAttribute('rating')) || 0;
const id = this.getAttribute('id') || '';
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
${name}
$${price.toFixed(2)}
${rating}
`;
}
}
customElements.define('product-card', ProductCard);