Declares the events this element can emit.
Emit a custom event with the given name and detail.
Event init options default to { bubbles: true, composed: true }.
Construct an event using the provided name and constructor.
The constructor will be called with the name as its first argument, followed by any subsequent arguments provided after the constructor.
A subclass of HTMLElement which declares what events can be emitted by it at the type level. Thus, calling
this.emit()with an undeclared event name will be a type error.It also offers proper type checking of the data provided to EmitterElement.emit using the types declared in HTMLElementEventMap.
Example