From d69cf702f3d6668736711113d42ae9e3025d41ea Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 20 Feb 2021 14:43:43 +0100 Subject: [PATCH] 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. --- src/display/api.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/display/api.js b/src/display/api.js index d3a9d6362..5bdcc7c87 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -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); } }