codebytere / codebytere/codebytere.github.io

localStorage usage is buggy

オープン
#16 コメント 1 件 リアクション 0 件 担当者 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 を短くまとめたダイジェスト。