[BUGFIX] Support CustomEvent in IE

This commit is contained in:
Xaver Maierhofer 2017-12-26 18:14:23 +01:00
parent 7fa0c5e522
commit a30d12312a
No known key found for this signature in database
GPG Key ID: 7FDCE23FD2EC9FE8
2 changed files with 20 additions and 2 deletions

View File

@ -15,7 +15,7 @@ define(function () {
el.appendChild(sidebar); el.appendChild(sidebar);
var button = document.createElement('button'); var button = document.createElement('button');
var visibility = new Event('visibility'); var visibility = new CustomEvent('visibility');
sidebar.appendChild(button); sidebar.appendChild(button);
button.classList.add('sidebarhandle'); button.classList.add('sidebarhandle');

View File

@ -30,3 +30,21 @@ if (typeof Object.assign !== 'function') {
return to; return to;
}; };
} }
// eslint-disable-next-line consistent-return
(function () {
if (typeof window.CustomEvent === 'function') {
return false;
}
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;
})();