Skip to content

Commit

Permalink
fix: nullify srcObject instead of calling removeAttribute (#1145)
Browse files Browse the repository at this point in the history
* fix: nullify srcObject instead of calling removeAttribute

* Update src/players/FilePlayer.js

Co-authored-by: Pete Cook <pete@cookpete.com>

Co-authored-by: Pete Cook <pete@cookpete.com>
  • Loading branch information
komachi and cookpete authored Jan 21, 2021
1 parent 593802d commit 22bf858
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/players/FilePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class FilePlayer extends Component {
this.props.url !== prevProps.url &&
!isMediaStream(this.props.url)
) {
this.player.removeAttribute('srcObject')
this.player.srcObject = null
}
}

Expand Down
3 changes: 1 addition & 2 deletions test/players/FilePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,7 @@ test('clear srcObject on url change', t => {
const url = new MockMediaStream()
const wrapper = shallow(<FilePlayer url={url} config={config} />)
const instance = wrapper.instance()
instance.player.removeAttribute = sinon.fake()
instance.load(url)
wrapper.setProps({ url: 'file.mpv' })
t.true(instance.player.removeAttribute.calledOnceWith('srcObject'))
t.is(instance.player.srcObject, null)
})

0 comments on commit 22bf858

Please sign in to comment.