1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-04 06:48:49 +02:00

test: fix travis ci issues with resize-manager tests (#5390)

This commit is contained in:
Brandon Casey 2018-08-28 16:24:26 -04:00 committed by GitHub
parent 4a299a7ffa
commit 3744df1680
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,7 +59,7 @@ class ResizeManager extends Component {
this.resizeObserver_ = null;
this.debouncedHandler_ = debounce(() => {
this.resizeHandler();
}, 100, false, player);
}, 100, false, this);
if (RESIZE_OBSERVER_AVAILABLE) {
this.resizeObserver_ = new this.ResizeObserver(this.debouncedHandler_);
@ -67,13 +67,14 @@ class ResizeManager extends Component {
} else {
this.loadListener_ = () => {
if (this.el_.contentWindow) {
Events.on(this.el_.contentWindow, 'resize', this.debouncedHandler_);
if (!this.el_ || this.el_.contentWindow) {
return;
}
this.off('load', this.loadListener_);
Events.on(this.el_.contentWindow, 'resize', this.debouncedHandler_);
};
this.on('load', this.loadListener_);
this.one('load', this.loadListener_);
}
}
@ -95,10 +96,20 @@ class ResizeManager extends Component {
* @event Player#playerresize
* @type {EventTarget~Event}
*/
// make sure player is still around to trigger
// prevents this from causing an error after dispose
if (!this.player_ || !this.player_.trigger) {
return;
}
this.player_.trigger('playerresize');
}
dispose() {
if (this.debouncedHandler_) {
this.debouncedHandler_.cancel();
}
if (this.resizeObserver_) {
if (this.player_.el()) {
this.resizeObserver_.unobserve(this.player_.el());
@ -114,15 +125,10 @@ class ResizeManager extends Component {
this.off('load', this.loadListener_);
}
if (this.debouncedHandler_) {
this.debouncedHandler_.cancel();
}
this.ResizeObserver = null;
this.resizeObserver = null;
this.debouncedHandler_ = null;
this.loadListener_ = null;
super.dispose();
}
}