Use modern JavaScript more in the extensions/firefox/tools/l10n.js
file
- Introduce optional chaining in a few spots. - Use more logical OR assignment in the code.
This commit is contained in:
parent
25cb4883e9
commit
8a2320bd18
@ -40,7 +40,7 @@
|
|||||||
property = "textContent";
|
property = "textContent";
|
||||||
}
|
}
|
||||||
const data = getL10nData(name);
|
const data = getL10nData(name);
|
||||||
const value = (data && data[property]) || fallback;
|
const value = data?.[property] || fallback;
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return "{{" + key + "}}";
|
return "{{" + key + "}}";
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
// translate an HTML element
|
// translate an HTML element
|
||||||
function translateElement(element) {
|
function translateElement(element) {
|
||||||
if (!element || !element.dataset) {
|
if (!element?.dataset) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@
|
|||||||
|
|
||||||
// translate an HTML subtree
|
// translate an HTML subtree
|
||||||
function translateFragment(element) {
|
function translateFragment(element) {
|
||||||
element = element || document.querySelector("html");
|
element ||= document.querySelector("html");
|
||||||
|
|
||||||
// check all translatable children (= w/ a `data-l10n-id' attribute)
|
// check all translatable children (= w/ a `data-l10n-id' attribute)
|
||||||
const children = element.querySelectorAll("*[data-l10n-id]");
|
const children = element.querySelectorAll("*[data-l10n-id]");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user