Skip to content

Commit

Permalink
Don't initialize L10n.#elements eagerly since it's unused in MOZCEN…
Browse files Browse the repository at this point in the history
…TRAL builds

It's not necessary to manually start translation in the Firefox PDF Viewer, and doing so would even cause problems there (see issue 17142).
  • Loading branch information
Snuffleupagus committed Oct 30, 2024
1 parent f013c39 commit cdd4b05
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions web/l10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class L10n {
#dir;

#elements = new Set();
#elements;

#lang;

Expand Down Expand Up @@ -71,7 +71,7 @@ class L10n {

/** @inheritdoc */
async translate(element) {
this.#elements.add(element);
(this.#elements ||= new Set()).add(element);
try {
this.#l10n.connectRoot(element);
await this.#l10n.translateRoots();
Expand All @@ -91,10 +91,13 @@ class L10n {

/** @inheritdoc */
async destroy() {
for (const element of this.#elements) {
this.#l10n.disconnectRoot(element);
if (this.#elements) {
for (const element of this.#elements) {
this.#l10n.disconnectRoot(element);
}
this.#elements.clear();
this.#elements = null;
}
this.#elements.clear();
this.#l10n.pauseObserving();
}

Expand Down

0 comments on commit cdd4b05

Please sign in to comment.