Skip to content

Commit 963e0e3

Browse files
author
Max Lynch
committed
Fixed #181 - CustomEvent polyfill
1 parent 223ba81 commit 963e0e3

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

dist/js/ionic.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,29 @@ window.ionic = {
217217
*/
218218

219219
(function(ionic) {
220+
221+
// Custom event polyfill
222+
223+
if(!window.CustomEvent) {
224+
var CustomEvent;
225+
226+
CustomEvent = function(event, params) {
227+
var evt;
228+
params = params || {
229+
bubbles: false,
230+
cancelable: false,
231+
detail: undefined
232+
};
233+
evt = document.createEvent("CustomEvent");
234+
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
235+
return evt;
236+
};
237+
238+
CustomEvent.prototype = window.Event.prototype;
239+
240+
window.CustomEvent = CustomEvent;
241+
}
242+
220243
ionic.EventController = {
221244
VIRTUALIZED_EVENTS: ['tap', 'swipe', 'swiperight', 'swipeleft', 'drag', 'hold', 'release'],
222245

js/utils/events.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,29 @@
1111
*/
1212

1313
(function(ionic) {
14+
15+
// Custom event polyfill
16+
17+
if(!window.CustomEvent) {
18+
var CustomEvent;
19+
20+
CustomEvent = function(event, params) {
21+
var evt;
22+
params = params || {
23+
bubbles: false,
24+
cancelable: false,
25+
detail: undefined
26+
};
27+
evt = document.createEvent("CustomEvent");
28+
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
29+
return evt;
30+
};
31+
32+
CustomEvent.prototype = window.Event.prototype;
33+
34+
window.CustomEvent = CustomEvent;
35+
}
36+
1437
ionic.EventController = {
1538
VIRTUALIZED_EVENTS: ['tap', 'swipe', 'swiperight', 'swipeleft', 'drag', 'hold', 'release'],
1639

0 commit comments

Comments
 (0)