I am trying to create my own class event with predefined parameters
class TimeoutEvent extends CustomEvent { constructor() { super(...arguments); this.bubbles = true; this.cancelable = true; this.type = 'timeout'; } } new TimeoutEvent();
but i get exeption:
Uncaught TypeError: Failed to construct 'CustomEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
i compile it with babel 5.8.23 (babel-core 5.8.25)
in compiled deletion of files on a line:
CustomEvent.apply(this, arguments);
I know that the true way is to use document.createEvent ("Event"); or the new CustomEvent (), but a way to extend the default DOM class?
source share