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";
|
||||
}
|
||||
const data = getL10nData(name);
|
||||
const value = (data && data[property]) || fallback;
|
||||
const value = data?.[property] || fallback;
|
||||
if (!value) {
|
||||
return "{{" + key + "}}";
|
||||
}
|
||||
@ -49,7 +49,7 @@
|
||||
|
||||
// translate an HTML element
|
||||
function translateElement(element) {
|
||||
if (!element || !element.dataset) {
|
||||
if (!element?.dataset) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@
|
||||
|
||||
// translate an HTML subtree
|
||||
function translateFragment(element) {
|
||||
element = element || document.querySelector("html");
|
||||
element ||= document.querySelector("html");
|
||||
|
||||
// check all translatable children (= w/ a `data-l10n-id' attribute)
|
||||
const children = element.querySelectorAll("*[data-l10n-id]");
|
||||
|
Loading…
Reference in New Issue
Block a user