From 1bbc47c64f6ad9dfbe58ab05ce65ec6ed9366c4c Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Sun, 28 Feb 2016 11:22:11 +1100 Subject: CustomEvent polyfill (Fixes #172) --- src/js/plyr.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/js/plyr.js b/src/js/plyr.js index 57544997..24c6d76d 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -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; })(); -- cgit v1.2.3