Skip to content

Instantly share code, notes, and snippets.

@parallaxisjones
Forked from gt3/customevent-polyfill.js
Created August 20, 2018 17:45
Show Gist options
  • Save parallaxisjones/f6ce80d2ce1a97a857e513748dae07f0 to your computer and use it in GitHub Desktop.
Save parallaxisjones/f6ce80d2ce1a97a857e513748dae07f0 to your computer and use it in GitHub Desktop.

Revisions

  1. Ankit revised this gist May 6, 2017. 1 changed file with 11 additions and 12 deletions.
    23 changes: 11 additions & 12 deletions customevent-polyfill.js
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,15 @@
    // source: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
    (function () {
    ;(function() {
    if (typeof window.CustomEvent === "function") return false

    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)
    return evt
    }

    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 );
    return evt;
    }
    CustomEvent.prototype = window.Event.prototype

    CustomEvent.prototype = window.Event.prototype;

    window.CustomEvent = CustomEvent;
    })();
    window.CustomEvent = CustomEvent
    })()
  2. Ankit created this gist May 6, 2017.
    16 changes: 16 additions & 0 deletions customevent-polyfill.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    // source: 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 );
    return evt;
    }

    CustomEvent.prototype = window.Event.prototype;

    window.CustomEvent = CustomEvent;
    })();