[BUGFIX] Support CustomEvent in IE
This commit is contained in:
parent
7fa0c5e522
commit
a30d12312a
@ -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');
|
||||
|
20
polyfill.js
20
polyfill.js
@ -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;
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user