1
0
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:
Gary Katsevman 2016-01-14 14:01:30 -05:00
parent 088f47af2e
commit dcf2a300ef
3 changed files with 11 additions and 2 deletions

View File

@ -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))
--------------------

View File

@ -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_);
}

View File

@ -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