Skip to content

Commit

Permalink
Cancel the requestAnimationFrame when all roots are disconnected
Browse files Browse the repository at this point in the history
Given that `pendingElements` was already being cleared, just below, there won't be anything to translate and as far as I can tell keeping the `requestAnimationFrame` running shouldn't be necessary.

Note that this was found in the PDF.js project, please refer to [this discussion](mozilla/pdf.js#18313 (comment)), where we're trying to shutdown various asynchronous operations when running tests and currently Fluent make this difficult.
  • Loading branch information
Snuffleupagus committed Jun 25, 2024
1 parent fee2242 commit b8142ec
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fluent-dom/src/dom_localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ export default class DOMLocalization extends Localization {

if (this.roots.size === 0) {
this.mutationObserver = null;
if (this.windowElement && this.pendingrAF) {
this.windowElement.cancelAnimationFrame(this.pendingrAF);
}
this.windowElement = null;
this.pendingrAF = null;
this.pendingElements.clear();
Expand Down

0 comments on commit b8142ec

Please sign in to comment.