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:
parent
3e30f83bb1
commit
11d37e28fd
@ -138,6 +138,10 @@ class Component {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.readyQueue_) {
|
||||
this.readyQueue_.length = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered when a `Component` is disposed.
|
||||
*
|
||||
|
@ -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');
|
||||
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user