Module

utils/dom/emittermixin

@ckeditor/ckeditor5-utils/src/dom/emittermixin

module

Filtering

Classes

  • ProxyEmitter

    private

    Creates a ProxyEmitter instance. Such an instance is a bridge between a DOM Node firing events and any Host listening to them. It is backwards compatible with on. There is a separate instance for each combination of modes (useCapture & usePassive). The mode is concatenated with UID stored in HTMLElement to give each instance unique identifier.

Interfaces

Functions

  • _getAllProxyEmitters( node ) → Array.<ProxyEmitter>

    private

    Retrieves all the ProxyEmitter instances for given DOM Node residing in this Host.

    Parameters

    node : Node

    DOM Node of the ProxyEmitter.

    Returns

    Array.<ProxyEmitter>
  • _getProxyEmitter( node, [ options ] = { [options.useCapture], [options.usePassive] } ) → ProxyEmitter | null

    private

    Retrieves ProxyEmitter instance for given DOM Node residing in this Host and given options.

    Parameters

    node : Node

    DOM Node of the ProxyEmitter.

    [ options ] : Object

    Additional options.

    Properties
    [ options.useCapture ] : Boolean

    Indicates that events of this type will be dispatched to the registered listener before being dispatched to any EventTarget beneath it in the DOM tree.

    Defaults to false

    [ options.usePassive ] : Boolean

    Indicates that the function specified by listener will never call preventDefault() and prevents blocking browser's main thread by this event handler.

    Defaults to false

    Returns

    ProxyEmitter | null

    ProxyEmitter instance bound to the DOM Node.

  • listenTo( emitter, event, callback, [ options ] = { [options.priority], [options.useCapture], [options.usePassive] } )

    Registers a callback function to be executed when an event is fired in a specific Emitter or DOM Node. It is backwards compatible with listenTo.

    Parameters

    emitter : Emitter | Node

    The object that fires the event.

    event : String

    The name of the event.

    callback : function

    The function to be called on event.

    [ options ] : Object

    Additional options.

    Properties
    [ options.priority ] : PriorityString | Number

    The priority of this event callback. The higher the priority value the sooner the callback will be fired. Events having the same priority are called in the order they were added.

    Defaults to 'normal'

    [ options.useCapture ] : Boolean

    Indicates that events of this type will be dispatched to the registered listener before being dispatched to any EventTarget beneath it in the DOM tree.

    Defaults to false

    [ options.usePassive ] : Boolean

    Indicates that the function specified by listener will never call preventDefault() and prevents blocking browser's main thread by this event handler.

    Defaults to false

    Defaults to {}

  • stopListening( [ emitter ], [ event ], [ callback ] )

    Stops listening for events. It can be used at different levels: It is backwards compatible with listenTo.

    • To stop listening to a specific callback.
    • To stop listening to a specific event.
    • To stop listening to all events fired by a specific object.
    • To stop listening to all events fired by all object.

    Parameters

    [ emitter ] : Emitter | Node

    The object to stop listening to. If omitted, stops it for all objects.

    [ event ] : String

    (Requires the emitter) The name of the event to stop listening to. If omitted, stops it for all events from emitter.

    [ callback ] : function

    (Requires the event) The function to be removed from the call list for the given event.