Event API

class wdom.event.Event(type, init=None)[source]

Bases: object

Event interface class.

Create event object.

First argument (type) is a string to represents type of this event. Second optional argument (init) is a dictionally, which has fields for this event’s status.


Return current event target.

Return type:Optional[WebEventTarget]

Return original event target, which emitted this event first.

Return type:Optional[WebEventTarget]

Not implemented yet.

Return type:None

Create Event from JSOM msg and set target nodes.

  • currentTarget (EventTarget) – Current event target node.
  • target (EventTarget) – Node which emitted this event first.
  • init (dict) – Event options.
Return type:


class wdom.event.EventListener(listener)[source]

Bases: object

Class to wrap an event listener function.

Acceptable listeners are function, coroutine, and coroutine-function. If listener is a coroutine or coroutine-function, it will be executed synchronously as if it is normal function.

Wrap an event listener.

Event listener should be function or coroutine-function.

class wdom.event.EventTarget(*args, **kwargs)[source]

Bases: object

Base class for EventTargets.

This class and subclasses can add/remove event listeners and emit events.


Need to check the target is mounted on document or not.

Return type:Optional[Node]
addEventListener(event, listener)[source]

Add event listener to this node.

event is a string which determines the event type when the new listener called. Acceptable events are same as JavaScript, without on. For example, to add a listener which is called when this node is clicked, event is 'click.

Return type:None
removeEventListener(event, listener)[source]

Remove an event listener of this node.

The listener is removed only when both event type and listener is matched.

Return type:None

Run before dispatching events.

Used for seting values changed by user input, in some elements like input, textarea, or select. In this method, event.currentTarget is a dict sent from browser.

Return type:None

Emit events.

Return type:None