Skip to content

Commit 07675e1

Browse files
committed
fix: add CustomEvent polyfill for ie11
1 parent 532aed6 commit 07675e1

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

js/index.umd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* --------------------------------------------------------------------------
66
*/
77

8+
import './src/polyfills'
89
import AsyncLoad from './src/async-load'
910
import Alert from './src/alert'
1011
import Button from './src/button'
@@ -19,7 +20,6 @@ import Sidebar from './src/sidebar'
1920
import Tab from './src/tab'
2021
import Toast from './src/toast'
2122
import Tooltip from './src/tooltip'
22-
import './src/polyfills'
2323

2424
export default {
2525
AsyncLoad,

js/src/polyfills.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,3 +498,22 @@ if (!('Promise' in globalNS)) {
498498
}
499499

500500
})));
501+
502+
(function () {
503+
if (
504+
typeof window.CustomEvent === "function" ||
505+
// In Safari, typeof CustomEvent == 'object' but it otherwise works fine
506+
this.CustomEvent.toString().indexOf('CustomEventConstructor')>-1
507+
) { return; }
508+
509+
function CustomEvent ( event, params ) {
510+
params = params || { bubbles: false, cancelable: false, detail: undefined };
511+
var evt = document.createEvent( 'CustomEvent' );
512+
evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
513+
return evt;
514+
}
515+
516+
CustomEvent.prototype = window.Event.prototype;
517+
518+
window.CustomEvent = CustomEvent;
519+
})();

0 commit comments

Comments
 (0)