Add a this-bound method for InternalRenderTask.cancel

This is similar to the other methods, and the only reason for this not having been done originally is that the `cancel` functionality is a later addition.
This commit is contained in:
Jonas Jenwald 2021-02-20 14:43:43 +01:00
parent 3d80c21a8e
commit d69cf702f3

View File

@ -2903,6 +2903,7 @@ const InternalRenderTask = (function InternalRenderTaskClosure() {
this.capability = createPromiseCapability();
this.task = new RenderTask(this);
// caching this-bound methods
this._cancelBound = this.cancel.bind(this);
this._continueBound = this._continue.bind(this);
this._scheduleNextBound = this._scheduleNext.bind(this);
this._nextBound = this._next.bind(this);
@ -3017,10 +3018,10 @@ const InternalRenderTask = (function InternalRenderTaskClosure() {
_scheduleNext() {
if (this._useRequestAnimationFrame) {
window.requestAnimationFrame(() => {
this._nextBound().catch(this.cancel.bind(this));
this._nextBound().catch(this._cancelBound);
});
} else {
Promise.resolve().then(this._nextBound).catch(this.cancel.bind(this));
Promise.resolve().then(this._nextBound).catch(this._cancelBound);
}
}