Skip to content

Removed the dead code #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions CustomEvent.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
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() {
if (typeof window === "undefined") return false;
if (typeof window.CustomEvent === "function") return false;

function register() {
}
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;
}

module.exports = function ( undefined ) {
if ( typeof window.CustomEvent === 'function' ) {
return;
};
CustomEvent.prototype = window.Event.prototype;

window.CustomEvent = CustomEvent;
};
})();
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ npm install --save-dev jspolyfill-custom-event
# Usage

```js
require( 'jspolyfill-custom-event' )();
require('jspolyfill-custom-event');
```

or

```js
import('jspolyfill-custom-event');
```

**Note**: Make sure to add the extra set of parenthesis at the end to fire the `function` that
registers the creation of the polyfill.

# Syntax

Expand Down