Skip to content

Commit

Permalink
Merge pull request #18979 from Snuffleupagus/L10n-#elements-lazy-init
Browse files Browse the repository at this point in the history
Don't initialize `L10n.#elements` eagerly since it's unused in MOZCENTRAL builds
  • Loading branch information
Snuffleupagus authored Oct 31, 2024
2 parents f013c39 + cdd4b05 commit 3ed438a
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 3ed438a

Please sign in to comment.