Weekly Commit #007
This week was slow. Vacation and a birthday meant I was only at the keyboard Monday and Tuesday.
A function that crashed the whole script
A function tried to read a property off an element that wasn't always there. When the element existed, everything worked. When it didn't, the whole thing threw and took the rest of the script down with it.
The fix was one line, guard for the missing element and return early:
if (!el) return;A second bug while I was in there
While I was in there, I found a second bug:
addEventListener("load", myFunction())Those parentheses mean the function runs immediately and its return value (undefined) gets registered as the listener. It was never actually running on load. Drop the parentheses and pass the reference, not the result.
Two tiny changes. No new feature. But the page stopped crashing and that counts.
The university project
Also, I got the beta version for the university project almost ready. I will be talking more about it in the next commit.
Not every week is a sprint. Some weeks you just make the thing a little less breakable than you found it.
#WeeklyCommit
Follow along here or on LinkedIn where I'll be sharing each new commit.