Skip to content

Commit

Permalink
Handle empty events array
Browse files Browse the repository at this point in the history
It's common to pre-emptively call `off` with an event and handler prior
to any handlers being registered. This is a safeguard to ensure that the
same handler isn't attached multiple times. In this scenario, the events
array isn't checked for existence prior to the accessor call (for the
given selector). Thus a TypeError is raised.

Closes ccampbell#31
  • Loading branch information
jasonkarns committed Dec 12, 2017
1 parent c864b70 commit 8549851
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gator.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
// if we have specified an event type, selector, and callback then we
// need to make sure there are callbacks tied to this selector to
// begin with. if there aren't then we can stop here
if (!_handlers[gator.id][event][selector]) {
if (!_handlers[gator.id][event] || !_handlers[gator.id][event][selector]) {
return;
}

Expand Down

0 comments on commit 8549851

Please sign in to comment.