From c0136dfc94106d584575738fe87fb2d85674712b Mon Sep 17 00:00:00 2001 From: Anvi3011 Date: Mon, 15 Jun 2026 00:55:06 +0530 Subject: [PATCH] fix: prevent auth button loader null reference crash --- public/js/auth.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/public/js/auth.js b/public/js/auth.js index 2e6771f..c3fba61 100644 --- a/public/js/auth.js +++ b/public/js/auth.js @@ -42,8 +42,8 @@ btn.style.cursor = 'not-allowed'; const btnContent = btn.querySelector('.btn-content'); const btnLoader = btn.querySelector('.btn-loader'); - btnContent.style.display = 'none'; - btnLoader.style.display = 'inline'; + if (btnContent) btnContent.style.display = 'none'; + if (btnLoader) btnLoader.style.display = 'inline'; try { const res = await fetch("/api/auth/login", { @@ -59,8 +59,8 @@ btn.textContent = "Sign In"; btn.style.opacity = '1'; btn.style.cursor = 'pointer'; - btnContent.style.display = 'flex'; - btnLoader.style.display = 'none'; + if (btnContent) btnContent.style.display = 'flex'; + if (btnLoader) btnLoader.style.display = 'none'; return; } @@ -71,8 +71,8 @@ btn.textContent = "Sign In"; btn.style.opacity = '1'; btn.style.cursor = 'pointer'; - btnContent.style.display = 'flex'; - btnLoader.style.display = 'none'; + if (btnContent) btnContent.style.display = 'flex'; + if (btnLoader) btnLoader.style.display = 'none'; } }); } @@ -343,8 +343,8 @@ const btnContent = btn.querySelector('.btn-content'); const btnLoader = btn.querySelector('.btn-loader'); -btnContent.style.display = 'none'; -btnLoader.style.display = 'inline'; + if (btnContent) btnContent.style.display = 'none'; + if (btnLoader) btnLoader.style.display = 'inline'; try { const res = await fetch("/api/auth/register", { @@ -360,8 +360,8 @@ btnLoader.style.display = 'inline'; btn.textContent = "Create Account"; btn.style.opacity = '1'; btn.style.cursor = 'pointer'; - btnContent.style.display = 'flex'; - btnLoader.style.display = 'none'; + if (btnContent) btnContent.style.display = 'flex'; + if (btnLoader) btnLoader.style.display = 'none'; return; } @@ -372,8 +372,8 @@ btnLoader.style.display = 'inline'; btn.textContent = "Create Account"; btn.style.opacity = '1'; btn.style.cursor = 'pointer'; - btnContent.style.display = 'flex'; - btnLoader.style.display = 'none'; + if (btnContent) btnContent.style.display = 'flex'; + if (btnLoader) btnLoader.style.display = 'none'; } }); }