Uncaught TypeError: недопустимый конструктор при расширении HTMLButtonElement
У меня есть следующий класс отсюда:
class FancyButton extends HTMLButtonElement {
constructor() {
super(); // always call super() first in the ctor.
this.addEventListener('click', e => this.drawRipple(e.offsetX, e.offsetY));
}
// Material design ripple animation.
drawRipple(x, y) {
let div = document.createElement('div');
div.classList.add('ripple');
this.appendChild(div);
div.style.top = `${y - div.clientHeight / 2}px`;
div.style.left = `${x - div.clientWidth / 2}px`;
div.style.backgroundColor = 'currentColor';
div.classList.add('run');
div.addEventListener('transitionend', e => div.remove());
}
}
Когда он создается, я получаю сообщение об ошибке:
fancy-button.js:5 Uncaught TypeError: Illegal constructor
Когда я нажимаю на местоположение, я получаю это:
((e) => { throw e; })
Что не так с конструктором класса?