-
Notifications
You must be signed in to change notification settings - Fork 33
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
Use pure empty object as storage, to prevent key conflicts #66
Use pure empty object as storage, to prevent key conflicts #66
Conversation
48be6ea
to
c83ef76
Compare
c83ef76
to
b5ac608
Compare
I'm not sure what's going on with CircleCI here... 🤔 |
@Kocal do we have a test for iterating over the keys in localstorage? And if not can you make sure that still works with this change? |
Tests for iterating over keys in local storage... I checked quickly (I am on smartphone atm) and there is no real tests for keys iterating. There is some tests for I will write a test asap I am on a pc. |
Well, it seems that my patch fucked up I will revert it and find a better solution to fix the original issue. 🤔 |
🙇 Thanks for looking into this! |
If you want to commit that new iteration test as a separate PR, please feel free to send this way. 💯 Grrrr 🔥 CircleCI |
Well, after many research and some experimentation, I was not able to reproduce the behavior of the real storage system... I can't iterate over storage data without having key conflicts. 😞 For now there is two possibilities:
In my own opinion, I think having no key conflicts is 12871829 times more important than having iteration support, but I may be wrong. |
Hmm, I wasn't aware of this behaviour until now, it'll take some rethinking of how we do functions and storage etc. localStorage.setItem('key', 'value')
> undefined
localStorage.key
> function key()
localStorage.getItem('key')
> "value" |
Hey, what should we do with this PR? I wasn't able to a solution for keeping iteration without key-names conflict. 😕 |
Ugh, I guess just waiting isn't solving this 😄 I don't want to revert the iteration that was requested and implemented previously but this does tend to create annoying errors. I think we'll have to leave this until we can find a new way to fix this and have both. |
For now, it is not possible to write
localStorage.getItem(key)
whenkey
is equal to'key'
,'clear'
, ... because those keys have the same name than some ofLocalStorage
mock properties.I added a failing test (because I didn't fixed it yet) which gives me this error
TypeError: Cannot assign to read only property 'key' of object '[object Object]'
.