codebytere / codebytere.github.io

personal website

Home Page:http://codebyte.re

Repository from Github https://github.comcodebytere/codebytere.github.ioRepository from Github https://github.comcodebytere/codebytere.github.io

localStorage usage is buggy

dsanders11 opened this issue · comments

Cool site. Seems the usage of localStorage is buggy though. In particular, in this line:

if (localStorage.inHistory && localStorage.historyIndex < history.length) {

localStorage.inHistory will always evaluate to be true. That's because everything put into localStorage is coerced to a string:

The keys and the values are always strings (note that, as with objects, integer keys will be automatically converted to strings).

So this line:

localStorage.inHistory = false // To prevent down arrow traversal when not required

is actually setting inHistory to the string "false", and Boolean("false") === true.

Doesn't look like your usage of localStorage persists between page loads (everything resets) so there's no real need to use it.

oh TIL! i wrote this thing a while ago so it seems it's time for some updates 😆

i'll try to get to this at a Soon Time™️