pseudo-dom
    Preparing search index...

    Class EventTargetService

    Simulate the behaviour of the EventTarget Class when there is no DOM available. Dispatching an event sends it through the tree the way the DOM does: down from the root to the target (capture listeners), to the target itself, then back up to the root (the listeners which are not capture listeners, when the event bubbles).

    Hierarchy (View Summary)

    Implements

    Index
    • Registers an event handler of a specific event type. Adding the same handler again for the same type and phase does nothing, like the DOM.

      Parameters

      • type: string

        The type of event to listen for

      • callback: any

        The function to call (or an object with a handleEvent function)

      • useCapture: boolean | listenerOptions = false

        Listen while the event travels down to the target (true), or an object with capture, once and passive

      Returns void

    • Dispatches an event to this target and through the tree: capture listeners of the ancestors from the root down, then the listeners of this target, then (when the event bubbles) the other listeners of the ancestors from the parent up to the root. stopPropagation() stops it reaching further targets, stopImmediatePropagation() also stops the remaining listeners of the current target. Afterwards, unless the default was prevented, the default action of this target (see setDefaultEvent) runs. The event can be dispatched again afterwards.

      Parameters

      Returns boolean

      False when the event was cancelable and a listener prevented the default, otherwise true

      When the event is already being dispatched, or (after the whole dispatch has finished) the error which a listener threw (an error with all of them in its errors property when several did)

    • Removes an event listener, the one which was added with the same type, handler and phase.

      Parameters

      • type: string

        The type of event

      • callback: Function

        The handler which was added

      • options: boolean | listenerOptions = false

        Whether the listener was a capture listener (true), or an object with capture

      Returns void

    • Register the function to run when nothing else has prevented the default for this type of event.

      Parameters

      • type: string
      • callback: Function

      Returns void