1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

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:
Jonas Jenwald 2024-10-31 11:03:24 +01:00 committed by GitHub
commit 3ed438aef5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -23,7 +23,7 @@
class L10n {
#dir;
#elements = new Set();
#elements;
#lang;
@ -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();
@ -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();
}