mirror of
https://github.com/videojs/video.js.git
synced 2024-11-24 08:42:25 +02:00
refactor: component.ready() (#4693)
This commit is contained in:
parent
a1748aa590
commit
b40858bc49
@ -598,18 +598,21 @@ class Component {
|
||||
* Returns itself; method can be chained.
|
||||
*/
|
||||
ready(fn, sync = false) {
|
||||
if (fn) {
|
||||
if (this.isReady_) {
|
||||
if (sync) {
|
||||
fn.call(this);
|
||||
} else {
|
||||
// Call the function asynchronously by default for consistency
|
||||
this.setTimeout(fn, 1);
|
||||
}
|
||||
} else {
|
||||
this.readyQueue_ = this.readyQueue_ || [];
|
||||
this.readyQueue_.push(fn);
|
||||
}
|
||||
if (!fn) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.isReady_) {
|
||||
this.readyQueue_ = this.readyQueue_ || [];
|
||||
this.readyQueue_.push(fn);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sync) {
|
||||
fn.call(this);
|
||||
} else {
|
||||
// Call the function asynchronously by default for consistency
|
||||
this.setTimeout(fn, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user