Skip to content

Commit 989d92e

Browse files
authored
Add polyfill for CustomEvent to fix #1186 (#1187)
* Add polyfill for CustomEvent to fix #1186
1 parent 5da07b5 commit 989d92e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/gridstack-poly.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
* gridstack.js may be freely distributed under the MIT license.
66
*/
77

8+
// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
9+
(function () {
10+
if (typeof window.CustomEvent === "function") {
11+
return false;
12+
}
13+
14+
function CustomEvent (event, params) {
15+
params = params || {bubbles: false, cancelable: false, detail: null};
16+
var evt = document.createEvent('CustomEvent');
17+
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
18+
return evt;
19+
}
20+
21+
window.CustomEvent = CustomEvent;
22+
})();
23+
824
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN
925
Number.isNaN = Number.isNaN || function isNaN(input) {
1026
return typeof input === 'number' && input !== input;

0 commit comments

Comments
 (0)