Skip to content

@serenity-is/domwise / removeDisposingListener

Function: removeDisposingListener()

removeDisposingListener<T>(target, handler, regKey?): T | null | undefined

Defined in: src/disposing-listener.ts:176

Removes a previously registered disposing listener from an element.

This removes the entry from the internal disposing-listener registry, not a direct DOM EventListener. When both handler and regKey are provided, a listener matches only when both its callback reference and its regKey match. When only one is provided, matching uses that one (by regKey, or by callback reference). When the last listener is removed the underlying disposing DOM listener is also detached from the target.

Type Parameters

T

T extends EventTarget

Type of the target event target.

Parameters

target

Element/event target to remove the listener from. No-op when null/undefined.

T | null | undefined

handler

Callback whose registration should be removed. If null/undefined, matching falls back to regKey.

() => void | null | undefined

regKey?

Optional registration key to match against.

string | null

Returns

T | null | undefined

The target that was passed in, for chaining.