Skip to content

Fix null-safety crashes in app.js DOM event bindings - #69

Draft
Stacey77 with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-bug-a
Draft

Fix null-safety crashes in app.js DOM event bindings#69
Stacey77 with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-bug-a

Conversation

Copilot AI commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

app.js called .addEventListener() directly on getElementById() results and accessed toast.textContent unconditionally — any missing DOM element would throw a TypeError and halt all remaining script execution.

Changes

  • Optional chaining on event listenerstheme-toggle, btn-share, btn-vcard, btn-install, btn-install-bottom now use ?.addEventListener(...) so a missing element is a no-op instead of a crash
  • showToast() null guard — added early return if #toast is absent
// Before
document.getElementById('btn-share').addEventListener('click', ...)
document.getElementById('btn-vcard').addEventListener('click', ...)

// After
document.getElementById('btn-share')?.addEventListener('click', ...)
document.getElementById('btn-vcard')?.addEventListener('click', ...)
// Before
const toast = document.getElementById('toast');
toast.textContent = message; // throws if element absent

// After
const toast = document.getElementById('toast');
if (!toast) return;
toast.textContent = message;

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rag7 Ready Ready Preview, Comment Jul 2, 2026 6:06pm

Copilot AI linked an issue Jul 2, 2026 that may be closed by this pull request
Open
Copilot AI changed the title [WIP] Fix bug related to issue A Fix null-safety crashes in app.js DOM event bindings Jul 2, 2026
Copilot AI requested a review from Stacey77 July 2, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A

2 participants