-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplified the usage by self invoking the function when it isrequired…
… or imported
- Loading branch information
Galeel Bhasha Satthar
committed
Oct 30, 2017
1 parent
987e7c9
commit 75229c1
Showing
2 changed files
with
19 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +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 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; | ||
}; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75229c1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplified the usage. Self-invoking function helps us to get rid of adding the extra set of parenthesis during the import or require.