From 54201631350a3fce12ae3e1c529682820deb3dad Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 27 Jan 2026 20:55:22 +0000 Subject: [PATCH] Fix UploadModal DOM initialization for robust testing Explicitly find the #uploadModal element within the parsed template wrapper using querySelector instead of relying on firstElementChild. This prevents null pointer exceptions in JSDOM environments where leading whitespace in the template string creates a text node as the first child. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- js/ui/components/UploadModal.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/ui/components/UploadModal.js b/js/ui/components/UploadModal.js index 75f71b42..905d78bb 100644 --- a/js/ui/components/UploadModal.js +++ b/js/ui/components/UploadModal.js @@ -160,11 +160,11 @@ export class UploadModal { wrapper.innerHTML = html; this.removeTrackingScripts(wrapper); - targetContainer.appendChild(wrapper.firstElementChild); - this.root = targetContainer.querySelector("#uploadModal"); - if (!this.root && targetContainer.lastElementChild && targetContainer.lastElementChild.id === "uploadModal") { - this.root = targetContainer.lastElementChild; - } + const modalRoot = wrapper.querySelector("#uploadModal"); + if (!modalRoot) throw new Error("UploadModal template must contain #uploadModal element"); + + targetContainer.appendChild(modalRoot); + this.root = modalRoot; this.container = targetContainer; this.cacheElements();