1
0
mirror of https://github.com/videojs/video.js.git synced 2025-02-02 11:34:50 +02:00

fix: clear readyQueue with dispose (#6967)

This commit is contained in:
Brandon Casey 2020-12-11 16:04:09 -05:00 committed by GitHub
parent 3e30f83bb1
commit 11d37e28fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View File

@ -138,6 +138,10 @@ class Component {
return;
}
if (this.readyQueue_) {
this.readyQueue_.length = 0;
}
/**
* Triggered when a `Component` is disposed.
*

View File

@ -1390,3 +1390,29 @@ QUnit.test('getDescendant should work as expected', function(assert) {
comp.dispose();
});
QUnit.test('ready queue should not run after dispose', function(assert) {
let option = false;
let callback = false;
const comp = new Component(this.player, {name: 'component'}, () => {
option = true;
});
comp.ready(() => {
callback = true;
});
comp.dispose();
comp.triggerReady();
// TODO: improve this error. It is a variant of:
// "Cannot read property 'parentNode' of null"
//
// but on some browsers such as IE 11 and safari 9 other errors are thrown,
// I think any error at all works for our purposes here.
assert.throws(() => this.clock.tick(1), /.*/, 'throws trigger error');
assert.notOk(option, 'ready option not run');
assert.notOk(callback, 'ready callback not run');
});