diff --git a/src/mixins/playable.js b/src/mixins/playable.js index e3efa31..2058b90 100644 --- a/src/mixins/playable.js +++ b/src/mixins/playable.js @@ -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; diff --git a/src/mixins/playable.test.js b/src/mixins/playable.test.js index 1a22ac0..dcb8c12 100644 --- a/src/mixins/playable.test.js +++ b/src/mixins/playable.test.js @@ -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', () => {