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
It returns all the keys, it removes the prefix but doesn't check if there is a prefix on this key.
If you have any other value in localstorage added by an external lib, the key will be returned and will be truncated.
The clear() method actually does the right thing in this regard, so I guess we should copy its looping-of-all-keys-and-checking-for-prefix code. Obviously MUCH slower, but then localStorage is our "bad driver" anyway...
Unless I'm mistaken, the functions keys and length don't really return the correct set of values:
The keys function:
It returns all the keys, it removes the prefix but doesn't check if there is a prefix on this key.
If you have any other value in localstorage added by an external lib, the key will be returned and will be truncated.
The length function:
It will return the total number of keys in localstorage, even if some are added by external libs, we should check for the prefix here too.
The text was updated successfully, but these errors were encountered: