Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
Refactoring of the module. Added few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrodek committed Aug 29, 2017
1 parent 6068091 commit 91e9c53
Show file tree
Hide file tree
Showing 28 changed files with 2,458 additions and 2,797 deletions.
8 changes: 7 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@
"undef": true,
"unused": true,
"newcap": false,
"mocha": true,
"globals": {
"chrome": true,
"URLSearchParams": true,
"URI": true,
"Cookies": true,
"FetchDigestAuth": true,
"FetchNtlmAuth": true,
"FetchBasicAuth": true
"FetchBasicAuth": true,
"Request": true,
"Headers": true,
"ArcEventSource": true,
"ArcRequest": true,
"ArcResponse": true
}
}
17 changes: 12 additions & 5 deletions app.event.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,30 @@
* Dispatches an Event at the specified EventTarget, invoking the affected EventListeners
* in the appropriate order.
*
* @type {Event} event An event to be dispatched.
* @param {Event} event An event to be dispatched.
* @return {Boolean} true if the event
*/
dispatchEvent(event) {
var type = event.type;
var cancelable = event.cancelable;
if (!type) {
throw new TypeError('Argument is not a valid event.');
}
if (!this.events.has(type)) {
return;
return false;
}
var set = this.events.get(type);
for (let listener of set) {
let canceled = listener(event);
if (event.cancelable && canceled) {
break;
try {
listener(event);
if (cancelable && event.defaultPrevented) {
return true;
}
} catch (e) {
console.error(e);
}
}
return false;
}
}

Expand Down
Loading

0 comments on commit 91e9c53

Please sign in to comment.