CustomEvent polyfill (Fixes #172)

This commit is contained in:
Sam Potts
2016-02-28 11:22:11 +11:00
parent 7a1a5830aa
commit 1bbc47c64f
5 changed files with 23 additions and 13 deletions

View File

@ -1,5 +1,6 @@
// ==========================================================================
// Plyr
// plyr.js v1.5.15
// https://github.com/selz/plyr
// License: The MIT License (MIT)
// ==========================================================================
@ -2832,16 +2833,18 @@
// Custom event polyfill
// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
(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 );
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
}
CustomEvent.prototype = window.Event.prototype;
if(!('CustomEvent' in window)) {
window.CustomEvent = CustomEvent;
}
window.CustomEvent = CustomEvent;
})();