-
-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object.keys(localStorage)
returns ['_store'] not the keys stored
#1181
Labels
bug
Something isn't working
Comments
Workaround: for (let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
// access each key
} |
frankdiw
pushed a commit
to frankdiw/happy-dom
that referenced
this issue
Feb 5, 2024
capricorn86
added a commit
to frankdiw/happy-dom
that referenced
this issue
Mar 21, 2024
…nStorage as Storage is the correct class to use
capricorn86
added a commit
to frankdiw/happy-dom
that referenced
this issue
Mar 21, 2024
…nStorage as Storage is the correct class to use
capricorn86
added a commit
that referenced
this issue
Mar 21, 2024
… by the properties Window.localStorage and Window.sessionStorage * fix: [#1181] Refactor storage mock * chore: [#1181] Removes the classes LocalStorage and SessionStorage as Storage is the correct class to use * chore: [#1181] Removes the classes LocalStorage and SessionStorage as Storage is the correct class to use --------- Co-authored-by: frankdiwang <[email protected]> Co-authored-by: David Ortner <[email protected]>
Than you for reporting @knownasilya! and @XiaoDaiGua-Ray! 🙂 A big thanks to @frankdiw for contributing with a fix 🌟 You can read more about the release here: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Object.keys(localStorage)
returns ['_store'] not the keys storedYou have to do
Object.keys(localStorage._store)
to get the keys.This also happens with for-in loop.
Using "happy-dom": "^12.10.3"
To Reproduce
Steps to reproduce the behavior:
Object.keys(localStorage)
Expected behavior
Object.keys(localStorage) should return keys that were set.
Device:
The text was updated successfully, but these errors were encountered: