From 3fd44dfdfff090ee19c640fe095bf61fada151fb Mon Sep 17 00:00:00 2001 From: Giddy Date: Wed, 5 Jul 2023 23:15:34 +0100 Subject: [PATCH] fix: simplify acquisition of form element When rendering the app for the first time, a brittle manual tree walk is used. Instead, query for the form element directly (as we expect there to only be one). This ensures that other minor modifications to the app don't break form acquisition. --- src/scripts/module.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/scripts/module.ts b/src/scripts/module.ts index f3fe749..d238b9d 100644 --- a/src/scripts/module.ts +++ b/src/scripts/module.ts @@ -62,10 +62,7 @@ Hooks.on("renderInvitationLinks", (links:InvitationLinks, html:JQuery) => { // If the window was reloaded, the JQuery is the Form let formHtml : HTMLFormElement | undefined; if(windowContent.classList.contains("window-app") && windowContent instanceof HTMLDivElement){ - let potentialForm = windowContent.lastElementChild?.lastElementChild; - if(potentialForm instanceof HTMLFormElement){ - formHtml = potentialForm; - } + formHtml = windowContent.querySelector("form"); } else if(windowContent instanceof HTMLFormElement){ formHtml = windowContent; }