interface.js: explicitly request to mount forms after creating elements

This commit is contained in:
dogeystamp 2023-01-31 14:38:56 -05:00
parent 949a0a0951
commit 10d913154c
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
3 changed files with 15 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "encryptme", "name": "encryptme",
"version": "0.5.0", "version": "0.5.1",
"description": "Simple online cryptography app.", "description": "Simple online cryptography app.",
"private": true, "private": true,
"scripts": { "scripts": {

View File

@ -155,6 +155,8 @@ let decManualKey = decForm.createCheckBox({
let decButton = decForm.createButton({label: "Decrypt"}); let decButton = decForm.createButton({label: "Decrypt"});
let decOut = decForm.createOutput({label: "Output"}); let decOut = decForm.createOutput({label: "Output"});
tabs.mountForms();
function getKeyMaterial(password) { function getKeyMaterial(password) {
let enc = new TextEncoder(); let enc = new TextEncoder();
return window.crypto.subtle.importKey( return window.crypto.subtle.importKey(

View File

@ -97,7 +97,7 @@ function dataTypeSupports(params, validTypes) {
} }
class Form extends InterfaceElement { class Form extends InterfaceElement {
constructor({tag, par=document.body, label}) { constructor({tag, par=document.body, label, mounted=false}) {
super({}); super({});
if (tag === undefined) { if (tag === undefined) {
@ -121,7 +121,9 @@ class Form extends InterfaceElement {
this.advanced = advancedToggle.value; this.advanced = advancedToggle.value;
}.bind(this)); }.bind(this));
par.appendChild(this.fragment); if (mounted) {
this.mount(par);
}
} }
#hidden = false; #hidden = false;
@ -488,7 +490,8 @@ class TabList extends InterfaceElement {
this.handle = tag; this.handle = tag;
} }
this.fragment.appendChild(this.handle); this.fragment.appendChild(this.handle);
par.appendChild(this.fragment);
this.mount(par);
} }
tabs = []; tabs = [];
@ -532,6 +535,12 @@ class TabList extends InterfaceElement {
return form; return form;
} }
mountForms() {
for (const tab of this.tabs) {
tab.form.mount(this.par);
}
}
} }
export { TabList, FormElement, Form }; export { TabList, FormElement, Form };