Skip to content

Commit

Permalink
fix exception when looking for event on instance during raise - fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
evs-chris committed Apr 20, 2018
1 parent 962ec7d commit f13926b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/shared/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,5 +322,5 @@ function findModel(ctx, path) {
}

function findEvent(el, name) {
return el.events && el.events.find(e => ~e.template.n.indexOf(name));
return el.events && el.events.find && el.events.find(e => ~e.template.n.indexOf(name));
}
11 changes: 11 additions & 0 deletions tests/browser/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -1081,4 +1081,15 @@ export default function() {
.hasListener('foo')
);
});

test(`raise with no matching event listener should not explode (#3226)`, t => {
t.expect(0);

const r = new Ractive({
template: '<div />',
target: fixture
});

r.getContext('div').raise('nope');
});
}

0 comments on commit f13926b

Please sign in to comment.