Skip to content

Commit

Permalink
fix(repo): Guard against an undefined player (#67)
Browse files Browse the repository at this point in the history
* Guard against an undefined player

* Added test for undefined player in detachHandlersFromPlayer
  • Loading branch information
marc-hughes authored and bringking committed Oct 20, 2017
1 parent 1d3b1df commit 904e3c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/mixins/playable.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export default {
player.oncancel = props.onCancel;
},
detachHandlersFromPlayer(player) {
player.onfinish = null;
player.oncancel = null;
if (player) {
player.onfinish = null;
player.oncancel = null;
}
},
notifyHandlers(event) {
const { player } = this.state;
Expand Down
4 changes: 4 additions & 0 deletions src/mixins/playable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ describe('playable', () => {
expect(player.onfinish).toBe(null);
expect(player.oncancel).toBe(null);
});

it('will not throw exception on undefined player', () => {
playable.detachHandlersFromPlayer(undefined);
});
});

describe('notifyHandlers', () => {
Expand Down

0 comments on commit 904e3c2

Please sign in to comment.