Skip to content

Commit

Permalink
fix: simplify acquisition of form element
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TheGiddyLimit authored Jul 5, 2023
1 parent 8345194 commit 3fd44df
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/scripts/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 3fd44df

Please sign in to comment.