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 merge when object is undefined #40

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lucianodltec
Copy link

Please check changes in merge.ts. That allows restoring initial null object from storage.

@codecov
Copy link

codecov bot commented Feb 13, 2021

Codecov Report

Merging #40 (2b44bb7) into master (57721d9) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #40   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines           98        99    +1     
  Branches        13        14    +1     
=========================================
+ Hits            98        99    +1     
Impacted Files Coverage Δ
src/merge.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 57721d9...731db17. Read the comment docs.

@maple3142
Copy link
Owner

Could you add a test case about this change?

@lucianodltec
Copy link
Author

Hi mapple3142.

In my app, I have vuex namespaced two modules. On system module, it does have a state called "auth" which is an object like the below:

auth = { token: '.....hold jwt token...', access: { 'GET/system/user': true, 'GET/system/role: true }, user: { id: 'some-guid', name: 'xxxx', } }

So, configure vuejs-storage to persist "system.auth" state. It writes OK on localStorage, but when I try to reload app it's raising an exception that could not use operator "in" to retrieve "user". I guess the "merge" code I propposed creates an empty "user" object so it can interacts creating user attrs id and name.

Hope this helps to understand. If not I'll try to give you an sample app.

Thanks for your attention.

@atilacamurca
Copy link

I had similar problems with attributes containing null values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants