MCPcopy Create free account
hub / github.com/nodejs/node / fireEvent

Function fireEvent

deps/undici/src/lib/web/websocket/util.js:56–70  ·  view source on GitHub ↗

* @see https://dom.spec.whatwg.org/#concept-event-fire * @param {string} e * @param {EventTarget} target * @param {(...args: ConstructorParameters ) => Event} eventFactory * @param {EventInit | undefined} eventInitDict * @returns {void}

(e, target, eventFactory = (type, init) => new Event(type, init), eventInitDict = {})

Source from the content-addressed store, hash-verified

54 * @returns {void}
55 */
56function fireEvent (e, target, eventFactory = (type, init) => new Event(type, init), eventInitDict = {}) {
57 // 1. If eventConstructor is not given, then let eventConstructor be Event.
58
59 // 2. Let event be the result of creating an event given eventConstructor,
60 // in the relevant realm of target.
61 // 3. Initialize event’s type attribute to e.
62 const event = eventFactory(e, eventInitDict)
63
64 // 4. Initialize any other IDL attributes of event as described in the
65 // invocation of this algorithm.
66
67 // 5. Return the result of dispatching event at target, with legacy target
68 // override flag set if set.
69 target.dispatchEvent(event)
70}
71
72/**
73 * @see https://websockets.spec.whatwg.org/#feedback-from-the-protocol

Callers 3

#onMessageMethod · 0.70
#onSocketCloseMethod · 0.70

Calls 1

dispatchEventMethod · 0.80

Tested by

no test coverage detected