Merge pull request #18979 from Snuffleupagus/L10n-#elements-lazy-init
Don't initialize `L10n.#elements` eagerly since it's unused in MOZCENTRAL builds
This commit is contained in:
commit
3ed438aef5
13
web/l10n.js
13
web/l10n.js
@ -23,7 +23,7 @@
|
|||||||
class L10n {
|
class L10n {
|
||||||
#dir;
|
#dir;
|
||||||
|
|
||||||
#elements = new Set();
|
#elements;
|
||||||
|
|
||||||
#lang;
|
#lang;
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class L10n {
|
|||||||
|
|
||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
async translate(element) {
|
async translate(element) {
|
||||||
this.#elements.add(element);
|
(this.#elements ||= new Set()).add(element);
|
||||||
try {
|
try {
|
||||||
this.#l10n.connectRoot(element);
|
this.#l10n.connectRoot(element);
|
||||||
await this.#l10n.translateRoots();
|
await this.#l10n.translateRoots();
|
||||||
@ -91,10 +91,13 @@ class L10n {
|
|||||||
|
|
||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
async destroy() {
|
async destroy() {
|
||||||
for (const element of this.#elements) {
|
if (this.#elements) {
|
||||||
this.#l10n.disconnectRoot(element);
|
for (const element of this.#elements) {
|
||||||
|
this.#l10n.disconnectRoot(element);
|
||||||
|
}
|
||||||
|
this.#elements.clear();
|
||||||
|
this.#elements = null;
|
||||||
}
|
}
|
||||||
this.#elements.clear();
|
|
||||||
this.#l10n.pauseObserving();
|
this.#l10n.pauseObserving();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user