leanwebclub/structure-and-scale/dice-component/script.js

19 lines
352 B
JavaScript

class RollDice extends HTMLElement {
constructor() {
super();
let userHTML = this.innerHTML.trim();
this.innerHTML = `
<p>
<button>${userHTML ? userHTML : 'Roll Dice'}</button>
</p>
<div aria-live="polite"></div>
`;
}
}
// Define the new web component
if ('customElements' in window) {
customElements.define('roll-dice', RollDice);
}