json-dom
    Preparing search index...

    Function addEventListener

    • Create an EventListener descriptor and push it onto a DomItem's eventListeners for the given event name. Does not attach anything to the real element - see bindListeners or fullAddEventListener for that.

      item is the last parameter (instead of customArgs/options having literal defaults) so this can be curried and piped directly - see fullAddEventListener for an example.

      Prefer calling this through fullAddEventListener with a registered name (see registerListener). Passing a raw function directly here works, but logs a console warning - see EventListener's listenerFunc property for what that discretionary path gives up.

      Parameters

      • eventName: string

        The name of the trigger event (e.g. 'click').

      • listenerFunction: string | ListenerFunction

        Preferably a name registered via registerListener; a raw listener function is also accepted, at the caller's discretion.

      • customArgs: object | null | undefined

        Additional args passed through to the listener when called.

      • options: ListenerOptions | null | undefined

        Options to be used when the listener is attached to the element.

      • item: DomItem

        The DomItem which will receive the event listener.

      Returns DomItem

      The same DomItem, with the new EventListener descriptor appended.