codebytere / codebytere/codebytere.github.io
localStorage usage is buggy
- 主要语言
- 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.
贡献指南
这个仓库没有索引到贡献指南
调研方向
先检查 js/shell.js 的第 12 行和第 42 行,然后复现 issue 中描述的 localStorage 行为,包括字符串 "false" 的求值方式。确认跨页面加载时预期的历史记录行为,并确保完成的更改不再将存储的 false 值视为 true。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- frontend
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100