MCPcopy
hub / github.com/ampproject/amphtml / createCustomEvent

Function createCustomEvent

src/utils/event-helper.js:21–39  ·  view source on GitHub ↗
(win, type, detail, opt_eventInit)

Source from the content-addressed store, hash-verified

19 * @return {!Event}
20 */
21export function createCustomEvent(win, type, detail, opt_eventInit) {
22 const eventInit = /** @type {!CustomEventInit} */ ({detail});
23 Object.assign(eventInit, opt_eventInit);
24 // win.CustomEvent is a function on Edge, Chrome, FF, Safari but
25 // is an object on IE 11.
26 if (mode.isEsm() || typeof win.CustomEvent == 'function') {
27 return new win.CustomEvent(type, eventInit);
28 } else {
29 // Deprecated fallback for IE.
30 const e = win.document.createEvent('CustomEvent');
31 e.initCustomEvent(
32 type,
33 !!eventInit.bubbles,
34 !!eventInit.cancelable,
35 detail
36 );
37 return e;
38 }
39}
40
41/**
42 * Listens for the specified event on the element.

Callers 15

test-amp-ad-3p.jsFile · 0.90
changeVisibilityFunction · 0.90
test-amp-img.jsFile · 0.90
test-action.jsFile · 0.90
dispatchCustomFunction · 0.90
test-amp-img.jsFile · 0.90
triggerEventMethod · 0.90
tickMethod · 0.90
constructorMethod · 0.90

Calls 1

assignMethod · 0.80

Tested by

no test coverage detected