mirror of
https://github.com/videojs/video.js.git
synced 2026-06-19 22:15:04 +02:00
@imbcmdth fix potential triggerReady infinite loop
This commit is contained in:
+3
-3
@@ -785,13 +785,13 @@ class Component {
|
||||
this.setTimeout(function(){
|
||||
let readyQueue = this.readyQueue_;
|
||||
|
||||
// Reset Ready Queue
|
||||
this.readyQueue_ = [];
|
||||
|
||||
if (readyQueue && readyQueue.length > 0) {
|
||||
readyQueue.forEach(function(fn){
|
||||
fn.call(this);
|
||||
}, this);
|
||||
|
||||
// Reset Ready Queue
|
||||
this.readyQueue_ = [];
|
||||
}
|
||||
|
||||
// Allow for using event listeners also
|
||||
|
||||
@@ -419,11 +419,13 @@ test('should not retrigger a listener when the listener calls triggerReady', fun
|
||||
}
|
||||
};
|
||||
|
||||
var comp = new vjs.Component(getFakePlayer(), {});
|
||||
var comp = new Component(getFakePlayer(), {});
|
||||
|
||||
comp.ready(readyListener);
|
||||
comp.triggerReady();
|
||||
|
||||
this.clock.tick(100);
|
||||
|
||||
equal(timesCalled, 1, 'triggerReady from inside a ready handler does not result in an infinite loop');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user