use text nodes instead of innerHTML

This commit is contained in:
dogeystamp 2022-12-30 19:48:28 -05:00
parent 610b20019b
commit caa1fccea3
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
2 changed files with 14 additions and 4 deletions

View File

@ -111,7 +111,7 @@ class FormElement extends InterfaceElement {
break; break;
case "button": case "button":
this.handle = document.createElement("button"); this.handle = document.createElement("button");
this.handle.innerHTML = label; this.handle.appendChild(document.createTextNode(label));
label = ""; label = "";
dataType = "none" dataType = "none"
break; break;
@ -125,7 +125,7 @@ class FormElement extends InterfaceElement {
if (label !== "") { if (label !== "") {
this.label = document.createElement("label"); this.label = document.createElement("label");
this.label.innerHTML = label; this.label.appendChild(document.createTextNode(label));
} }
this.dataType = dataType; this.dataType = dataType;
@ -230,11 +230,11 @@ class FormElement extends InterfaceElement {
let box = document.createElement("div"); let box = document.createElement("div");
box.classList.add(type); box.classList.add(type);
box.classList.add("alert"); box.classList.add("alert");
box.innerHTML = message; box.appendChild(document.createTextNode(message));
if (title !== "") { if (title !== "") {
let titleTag = document.createElement("strong"); let titleTag = document.createElement("strong");
titleTag.innerHTML = title; titleTag.appendChild(document.createTextNode(title));
box.prepend(titleTag); box.prepend(titleTag);
} }

View File

@ -40,6 +40,13 @@ let out = new FormElement({
form: form form: form
}); });
let button = new FormElement({
id: "button",
type: "button",
label: "Do things",
form: form
});
let outAdvanced = new FormElement({ let outAdvanced = new FormElement({
id: "output-advanced", id: "output-advanced",
type: "output", type: "output",
@ -47,3 +54,6 @@ let outAdvanced = new FormElement({
advanced: true, advanced: true,
form: form form: form
}); });
inp.alertBox("alert-info", "Pater noster qui es in caelo sanctificetur nomen tuum adveniat regnum tuum.");
button.handle.addEventListener("click", form.clearAlerts);