* Create a custom event and immediately sent it from the given element. * By default, if no element is given, the event is thrown from `document`. * * @param {string} eventName * @param {HTMLElement|HTMLDocument|EventTarget} element * @param {object} [detail=null] * @pa
(eventName, element = document, detail = null, bubbles = true, cancelable = true)
| 1070 | * @param {boolean} [cancelable=true] Set to `true` if the event must be cancelable |
| 1071 | */ |
| 1072 | static triggerEvent(eventName, element = document, detail = null, bubbles = true, cancelable = true) { |
| 1073 | let event; |
| 1074 | if (window.CustomEvent) { |
| 1075 | event = new CustomEvent(eventName, { detail, bubbles , cancelable }); // This is not supported by default by IE ; We use the polyfill for IE9 and later. |
| 1076 | } else { |
| 1077 | event = document.createEvent('CustomEvent'); |
| 1078 | event.initCustomEvent(eventName, bubbles, cancelable, { detail }); |
| 1079 | } |
| 1080 | |
| 1081 | element.dispatchEvent(event); |
| 1082 | } |
| 1083 | |
| 1084 | /** |
| 1085 | * This typedef is based on big.js object properties: https://mikemcl.github.io/big.js/#instance-properties |
no outgoing calls
no test coverage detected