Added method to retrieve element or throw

This commit is contained in:
squidfunk
2020-02-14 09:52:22 +01:00
parent 718b51bac9
commit 8c92565b7b
6 changed files with 50 additions and 29 deletions

View File

@@ -20,7 +20,7 @@
* IN THE SOFTWARE.
*/
import { getElement } from "observables"
import { getElementOrThrow } from "observables"
/* ----------------------------------------------------------------------------
* Data
@@ -45,7 +45,7 @@ let lang: Record<string, string>
*/
export function translate(key: string, value?: string): string {
if (typeof lang === "undefined") {
const el = getElement("#__lang")!
const el = getElementOrThrow("#__lang")
lang = JSON.parse(el.innerText)
}
if (typeof lang[key] === "undefined") {