mirror of
https://github.com/videojs/video.js.git
synced 2024-11-28 08:58:46 +02:00
make sure that styleEl_ is in DOM before removing on dispose. closes #3004
This commit is contained in:
parent
088f47af2e
commit
dcf2a300ef
@ -2,7 +2,7 @@ CHANGELOG
|
||||
=========
|
||||
|
||||
## HEAD (Unreleased)
|
||||
_(none)_
|
||||
* make sure that styleEl_ is in DOM before removing on dispose ([view](https://github.com/videojs/video.js/pull/3004))
|
||||
|
||||
--------------------
|
||||
|
||||
|
@ -224,7 +224,7 @@ class Player extends Component {
|
||||
// prevent dispose from being called twice
|
||||
this.off('dispose');
|
||||
|
||||
if (this.styleEl_) {
|
||||
if (this.styleEl_ && this.styleEl_.parentNode) {
|
||||
this.styleEl_.parentNode.removeChild(this.styleEl_);
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,15 @@ test('should create player instance that inherits from component and dispose it'
|
||||
ok(player.el() === null, 'element disposed');
|
||||
});
|
||||
|
||||
test('dispose should not throw if styleEl is missing', function(){
|
||||
var player = TestHelpers.makePlayer();
|
||||
|
||||
player.styleEl_.parentNode.removeChild(player.styleEl_);
|
||||
|
||||
player.dispose();
|
||||
ok(player.el() === null, 'element disposed');
|
||||
});
|
||||
|
||||
// technically, all uses of videojs.options should be replaced with
|
||||
// Player.prototype.options_ in this file and a equivalent test using
|
||||
// videojs.options should be made in video.test.js. Keeping this here
|
||||
|
Loading…
Reference in New Issue
Block a user