Skip to content

Commit

Permalink
fail silently if emitting a nonexistant event
Browse files Browse the repository at this point in the history
  • Loading branch information
callmecavs committed Dec 17, 2015
1 parent 225846f commit c74b703
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions dist/knot.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "knot.js",
"version": "0.2.0",
"version": "0.2.1",
"description": "A browser-based emitter, for tying together event handlers.",
"homepage": "https://github.com/callmecavs/knot",
"main": "dist/knot.min.js",
Expand Down
6 changes: 3 additions & 3 deletions src/knot.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export default (object = {}) => {

object.emit = function(name, ...args) {
// cache event state, to avoid consequences of mutation from splice while firing handlers
const cached = object.events[name].slice()
const cached = object.events[name] && object.events[name].slice()

// fire handlers
cached.forEach(handler => {
// if they exist, fire handlers
cached && cached.forEach(handler => {
// remove handler if added with `once`
handler._once && object.off(name, handler)

Expand Down

0 comments on commit c74b703

Please sign in to comment.