Skip to content

Commit 8e704f1

Browse files
author
TechStack Global
committed
fix: guard getElementById('year') against null to prevent script crash on pages missing the span
Pages like amazon-stack.html use a static copyright string without the #year span. The TypeError crashed script.js before the toggle event listener was attached, breaking the hamburger on all such pages. Added a null guard: only 1 line changed in script.js.
1 parent 8ef55b0 commit 8e704f1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

script.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Minimal JS for interactions (No 3D canvas libraries)
22
document.addEventListener('DOMContentLoaded', () => {
33
// Current Year for Footer
4-
document.getElementById('year').textContent = new Date().getFullYear();
4+
const yearEl = document.getElementById('year');
5+
if (yearEl) yearEl.textContent = new Date().getFullYear();
56

67
// Mobile Menu Toggle
78
const menuToggle = document.querySelector('.menu-toggle');

0 commit comments

Comments
 (0)