You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that clear() does not always remove all keys. This happens when there's another key in the SessionStorage that does not have the store prefix (in my case it was a browser extension).
The current implementation iterates over all keys and removes them if they have the store prefix. The remove operation, however, might mess with the order of keys that are returned by key(i). In my case, key(i) returned the same key for a different i. MDN writes about key():
The order of keys is user-agent defined, so you should not rely on it.
The current implementation can be fixed by first getting all the keys via Object.keys() and then iterating over that array. Object.keys() has good browser support these days but I don't know if that's ok for you. You could also iterate with for ... in.
Are you interested in a fix with Object.keys()? I could send a PR.
The text was updated successfully, but these errors were encountered:
Hi 👋,
first of all: thanks for this library ❤️
I noticed that
clear()
does not always remove all keys. This happens when there's another key in the SessionStorage that does not have the store prefix (in my case it was a browser extension).The current implementation iterates over all keys and removes them if they have the store prefix. The remove operation, however, might mess with the order of keys that are returned by
key(i)
. In my case,key(i)
returned the same key for a differenti
. MDN writes aboutkey()
:The current implementation can be fixed by first getting all the keys via
Object.keys()
and then iterating over that array.Object.keys()
has good browser support these days but I don't know if that's ok for you. You could also iterate withfor ... in
.Are you interested in a fix with
Object.keys()
? I could send a PR.The text was updated successfully, but these errors were encountered: