Skip to content
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

Fix localStorageStore.reset() does not remove all items #8161

Merged
merged 2 commits into from
Sep 15, 2022

Conversation

fzaninotto
Copy link
Member

I have a unit test for it in the configurable branch - I haven't added ift here to avoi!d conflicts

@@ -116,15 +116,11 @@ export const localStorageStore = (
},
reset(): void {
const storage = getStorage();
for (let i = 0; i < storage.length; i++) {
if (storage.key(i)?.substring(0, prefixLength) === prefix) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem was that once you remove an item, the index of the next item decreases... So storage.key(i) 'jumps' one item each time we delete one.

@slax57 slax57 added this to the 4.3.3 milestone Sep 15, 2022
@slax57 slax57 merged commit fe1e4c3 into master Sep 15, 2022
@slax57 slax57 deleted the fix-store-removeitems branch September 15, 2022 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants