19 lines
352 B
JavaScript
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);
|
|
}
|