Skip to content

Commit

Permalink
Add CustomEvent Pollyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
hyyan committed Mar 1, 2018
1 parent d7e245e commit 0e0a740
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions js/src/events.js
Expand Up @@ -6,6 +6,7 @@
* file that was distributed with this source code.
*/

export * from './events/pollyfill.js';
export * from './events/utilities.js';
export * from './events/selections.js';
export * from './events/editing.js';
15 changes: 15 additions & 0 deletions js/src/events/pollyfill.js
@@ -0,0 +1,15 @@
/** https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent */
(function () {
if (typeof window.CustomEvent === "function") return false; //If not IE

function CustomEvent(event, params) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
}

CustomEvent.prototype = window.Event.prototype;

window.CustomEvent = CustomEvent;
})();
2 changes: 1 addition & 1 deletion js/src/events/utilities.js
Expand Up @@ -13,7 +13,7 @@ export function gw_postEvent(ev) {
export function gw_sendEvent(payload) {

const d = $doc.getElementById('eventTransporterDiv');
const event = new Event('click');
const event = new CustomEvent('click');
event.payload = payload;
d.dispatchEvent(event);
}
Expand Down

0 comments on commit 0e0a740

Please sign in to comment.