diff --git a/src/scripting_api/app.js b/src/scripting_api/app.js index 7c4235186..3c8619615 100644 --- a/src/scripting_api/app.js +++ b/src/scripting_api/app.js @@ -152,13 +152,10 @@ class App extends PDFObject { } static _getLanguage(language) { - const [main, sub] = language.toLowerCase().split(/[-_]/); + const [main, sub] = language.toLowerCase().split(/[-_]/, 2); switch (main) { case "zh": - if (sub === "cn" || sub === "sg") { - return "CHS"; - } - return "CHT"; + return sub === "cn" || sub === "sg" ? "CHS" : "CHT"; case "da": return "DAN"; case "de": @@ -178,10 +175,7 @@ class App extends PDFObject { case "no": return "NOR"; case "pt": - if (sub === "br") { - return "PTB"; - } - return "ENU"; + return sub === "br" ? "PTB" : "ENU"; case "fi": return "SUO"; case "SV": @@ -249,13 +243,10 @@ class App extends PDFObject { } get fs() { - if (this._fs === null) { - this._fs = new Proxy( - new FullScreen({ send: this._send }), - this._proxyHandler - ); - } - return this._fs; + return (this._fs ??= new Proxy( + new FullScreen({ send: this._send }), + this._proxyHandler + )); } set fs(_) { @@ -356,13 +347,10 @@ class App extends PDFObject { } get thermometer() { - if (this._thermometer === null) { - this._thermometer = new Proxy( - new Thermometer({ send: this._send }), - this._proxyHandler - ); - } - return this._thermometer; + return (this._thermometer ??= new Proxy( + new Thermometer({ send: this._send }), + this._proxyHandler + )); } set thermometer(_) { diff --git a/src/scripting_api/field.js b/src/scripting_api/field.js index b5de544e7..5e355d924 100644 --- a/src/scripting_api/field.js +++ b/src/scripting_api/field.js @@ -453,11 +453,9 @@ class Field extends PDFObject { return array; } - if (this._children === null) { - this._children = this._document.obj._getTerminalChildren(this._fieldPath); - } - - return this._children; + return (this._children ??= this._document.obj._getTerminalChildren( + this._fieldPath + )); } getLock() {