@imbcmdth fix potential triggerReady infinite loop

This commit is contained in:
heff
2015-09-29 09:28:02 -07:00
parent e225fbffc2
commit cd6c568a03
2 changed files with 6 additions and 4 deletions
+3 -3
View File
@@ -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
+3 -1
View File
@@ -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');
});