Skip to content

Component.registerDomEvent method

Component › registerDomEvent

Official

Registers a DOM event to be detached when unloading.

Signature:

registerDomEvent(el: Window, type: K, callback: (this: HTMLElement, ev: WindowEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions | undefined): void

Parameters:

ParameterTypeDescription
elWindowThe element to register the event on.
typeKThe type of the event to register.
callback(this: HTMLElement, ev: WindowEventMap[K]) => unknownThe callback to be called when the event is triggered.
options?boolean | AddEventListenerOptions | undefinedThe options for the event.

Returns: void

Example:

component.registerDomEvent(window, 'click', () => {
console.log('Window clicked');
});

Official

Registers a DOM event to be detached when unloading

Signature:

registerDomEvent(el: Document, type: K, callback: (this: HTMLElement, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): void

Parameters:

ParameterTypeDescription
elDocument
typeK
callback(this: HTMLElement, ev: DocumentEventMap[K]) => any
options?boolean | AddEventListenerOptions | undefined*(Optional)*

Returns: void

Since: 0.14.8


Official

Registers a DOM event to be detached when unloading

Signature:

registerDomEvent(el: HTMLElement, type: K, callback: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): void

Parameters:

ParameterTypeDescription
elHTMLElement
typeK
callback(this: HTMLElement, ev: HTMLElementEventMap[K]) => any
options?boolean | AddEventListenerOptions | undefined*(Optional)*

Returns: void

Since: 0.14.8