[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);
var button = document.createElement('button');
var visibility = new Event('visibility');
var visibility = new CustomEvent('visibility');
sidebar.appendChild(button);
button.classList.add('sidebarhandle');

View File

@ -8,7 +8,7 @@ if (!String.prototype.includes) {
}
if (typeof Object.assign !== 'function') {
Object.assign = function(target, varArgs) { // .length of function is 2
Object.assign = function (target, varArgs) { // .length of function is 2
if (target == null) { // TypeError if undefined or null
throw new TypeError('Cannot convert undefined or null to object');
}
@ -30,3 +30,21 @@ if (typeof Object.assign !== 'function') {
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;
})();