mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1847574 - Do not de-lazify the panel when modifying the translations button; r=nordzilla
Differential Revision: https://phabricator.services.mozilla.com/D185583
This commit is contained in:
parent
0e92f78d74
commit
be4f1175dc
@ -298,9 +298,6 @@ var TranslationsPanel = new (class {
|
||||
|
||||
// Getters by id
|
||||
getter("appMenuButton", "PanelUI-menu-button");
|
||||
getter("button", "translations-button");
|
||||
getter("buttonLocale", "translations-button-locale");
|
||||
getter("buttonCircleArrows", "translations-button-circle-arrows");
|
||||
getter("cancelButton", "translations-panel-cancel");
|
||||
getter(
|
||||
"changeSourceLanguageButton",
|
||||
@ -340,6 +337,26 @@ var TranslationsPanel = new (class {
|
||||
return this.#lazyElements;
|
||||
}
|
||||
|
||||
#lazyButtonElements = null;
|
||||
|
||||
/**
|
||||
* When accessing `this.elements` the first time, it de-lazifies the custom components
|
||||
* that are needed for the popup. Avoid that by having a second element lookup
|
||||
* just for modifying the button.
|
||||
*/
|
||||
get buttonElements() {
|
||||
if (!this.#lazyButtonElements) {
|
||||
this.#lazyButtonElements = {
|
||||
button: document.getElementById("translations-button"),
|
||||
buttonLocale: document.getElementById("translations-button-locale"),
|
||||
buttonCircleArrows: document.getElementById(
|
||||
"translations-button-circle-arrows"
|
||||
),
|
||||
};
|
||||
}
|
||||
return this.#lazyButtonElements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache the last command used for error hints so that it can be later removed.
|
||||
*/
|
||||
@ -1150,7 +1167,7 @@ var TranslationsPanel = new (class {
|
||||
gBrowser.selectedBrowser.browsingContext.top.embedderElement.ownerGlobal;
|
||||
window.ensureCustomElements("moz-support-link");
|
||||
|
||||
const { button } = this.elements;
|
||||
const { button } = this.buttonElements;
|
||||
|
||||
const { requestedTranslationPair, locationChangeId } =
|
||||
this.#getTranslationsActor().languageState;
|
||||
@ -1203,7 +1220,7 @@ var TranslationsPanel = new (class {
|
||||
* Removes the translations button.
|
||||
*/
|
||||
#hideTranslationsButton() {
|
||||
const { button, buttonLocale, buttonCircleArrows } = this.elements;
|
||||
const { button, buttonLocale, buttonCircleArrows } = this.buttonElements;
|
||||
button.hidden = true;
|
||||
buttonLocale.hidden = true;
|
||||
buttonCircleArrows.hidden = true;
|
||||
@ -1408,7 +1425,8 @@ var TranslationsPanel = new (class {
|
||||
isEngineReady,
|
||||
} = event.detail;
|
||||
|
||||
const { button, buttonLocale, buttonCircleArrows } = this.elements;
|
||||
const { button, buttonLocale, buttonCircleArrows } =
|
||||
this.buttonElements;
|
||||
|
||||
const hasSupportedLanguage =
|
||||
detectedLanguages?.docLangTag &&
|
||||
|
@ -440,6 +440,8 @@ function maybeGetByL10nId(l10nId, doc = document) {
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function waitForTranslationsPopupEvent(eventName, callback) {
|
||||
// De-lazify the panel elements.
|
||||
TranslationsPanel.elements;
|
||||
const panel = document.getElementById("translations-panel");
|
||||
if (!panel) {
|
||||
throw new Error("Unable to find the translations panel element.");
|
||||
|
Loading…
Reference in New Issue
Block a user