1 | interface EventListener {
|
2 | (evt: Event): void;
|
3 | }
|
4 |
|
5 | /**
|
6 | * The Event interface represents any event which takes place in the DOM; some are user-generated (such as mouse or keyboard events), while others are generated by APIs (such as
|
7 | * events that indicate an animation has finished running, a video has been paused, and so forth). While events are usually triggered by such "external" sources, they can also be
|
8 | * triggered programmatically, such as by calling the HTMLElement.click() method of an element, or by defining the event, then sending it to a specified target using
|
9 | * EventTarget.dispatchEvent(). There are many types of events, some of which use other interfaces based on the main Event interface. Event itself contains the properties and
|
10 | * methods which are common to all events.
|
11 | */
|
12 | interface Event {
|
13 | /**
|
14 | * Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise.
|
15 | */
|
16 | readonly bubbles: boolean;
|
17 | cancelBubble: boolean;
|
18 | readonly cancelable: boolean;
|
19 | /**
|
20 | * Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise.
|
21 | */
|
22 | readonly composed: boolean;
|
23 | readonly defaultPrevented: boolean;
|
24 | readonly eventPhase: number;
|
25 | /**
|
26 | * Returns true if event was dispatched by the user agent, and
|
27 | * false otherwise.
|
28 | */
|
29 | readonly isTrusted: boolean;
|
30 | returnValue: boolean;
|
31 | /**
|
32 | * Returns the event's timestamp as the number of milliseconds measured relative to
|
33 | * the time origin.
|
34 | */
|
35 | readonly timeStamp: number;
|
36 | /**
|
37 | * Returns the type of event, e.g.
|
38 | * "click", "hashchange", or
|
39 | * "submit".
|
40 | */
|
41 | readonly type: string;
|
42 | readonly AT_TARGET: number;
|
43 | readonly BUBBLING_PHASE: number;
|
44 | readonly CAPTURING_PHASE: number;
|
45 | readonly NONE: number;
|
46 | composedPath(): any[];
|
47 | initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
|
48 | preventDefault(): void;
|
49 | /**
|
50 | * Invoking this method prevents event from reaching
|
51 | * any registered event listeners after the current one finishes running and, when dispatched in a tree, also prevents event from reaching any
|
52 | * other objects.
|
53 | */
|
54 | stopImmediatePropagation(): void;
|
55 | /**
|
56 | * When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object.
|
57 | */
|
58 | stopPropagation(): void;
|
59 | }
|
60 |
|
61 | interface EventInit {
|
62 | bubbles?: boolean | undefined;
|
63 | cancelable?: boolean | undefined;
|
64 | composed?: boolean | undefined;
|
65 | }
|
66 |
|
67 | interface MessageEventInit<T = any> extends EventInit {
|
68 | data?: T | undefined;
|
69 | lastEventId?: string | undefined;
|
70 | origin?: string | undefined;
|
71 | }
|
72 |
|
73 | /** The MessageEvent interface represents a message received by a target object. */
|
74 | interface MessageEvent<T = any> extends Event {
|
75 | /**
|
76 | * Returns the data of the message.
|
77 | */
|
78 | readonly data: T;
|
79 | /**
|
80 | * Returns the last event ID string, for server-sent events.
|
81 | */
|
82 | readonly lastEventId: string;
|
83 | /**
|
84 | * Returns the origin of the message, for server-sent events and
|
85 | * cross-document messaging.
|
86 | */
|
87 | readonly origin: string;
|
88 | }
|
89 | declare var MessageEvent: {
|
90 | prototype: MessageEvent;
|
91 | new<T>(type: string, eventInitDict?: MessageEventInit<T>): MessageEvent<T>;
|
92 | };
|