forked from MapComplete/MapComplete
Add fakedom to test UI code, replace all 'innerText' with 'textContent' as it is not compatible with fakedom
This commit is contained in:
parent
b0b674b2fb
commit
0f66d7f8cc
17 changed files with 281 additions and 20 deletions
|
@ -112,6 +112,15 @@ export class Translation extends BaseUIElement {
|
|||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* const tr = new Translation({"en":"English", nl: "Nederlands"})
|
||||
* Locale.language.setData("en")
|
||||
* const html = tr.InnerConstructElement()
|
||||
* html.innerHTML // => "English"
|
||||
* Locale.language.setData("nl")
|
||||
* html.innerHTML // => "Nederlands"
|
||||
*/
|
||||
InnerConstructElement(): HTMLElement {
|
||||
const el = document.createElement("span")
|
||||
const self = this
|
||||
|
@ -121,7 +130,7 @@ export class Translation extends BaseUIElement {
|
|||
if (self.isDestroyed) {
|
||||
return true
|
||||
}
|
||||
el.innerHTML = this.txt
|
||||
el.innerHTML = self.txt
|
||||
})
|
||||
|
||||
if (self.translations["*"] !== undefined || self.context === undefined || self.context?.indexOf(":") < 0) {
|
||||
|
|
|
@ -12,7 +12,7 @@ export default class Translations {
|
|||
throw "Translations is static. If you want to intitialize a new translation, use the singular form"
|
||||
}
|
||||
|
||||
public static W(s: string | BaseUIElement): BaseUIElement {
|
||||
public static W(s: string | number | BaseUIElement): BaseUIElement {
|
||||
if (typeof (s) === "string") {
|
||||
return new FixedUiElement(s);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue