codebytere / codebytere/codebytere.github.io

localStorage usage is buggy

未關閉
#16 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
JavaScript
星號
546
分支
105
PR 合併指標
30 天內沒有已合併 PR

描述

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

https://github.com/codebytere/codebytere.github.io/blob/3d5854bea758dfe0266b6ffc4b77a0b03a0cb782/js/shell.js#L42

`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).](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage)

So this line:

https://github.com/codebytere/codebytere.github.io/blob/3d5854bea758dfe0266b6ffc4b77a0b03a0cb782/js/shell.js#L12

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.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。