Skip to content

Commit

Permalink
fix(constructor): add each item one by one to fix it if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
leomp12 committed Aug 29, 2019
1 parent 3ab6636 commit 874b000
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function (storeId, storageKey = _key, localStorage = _storage) {
if (localStorage && storageKey) {
// try to preset cart data from storage
const json = localStorage.getItem(storageKey)
if (typeof data === 'string') {
if (json) {
let data
try {
data = JSON.parse(json)
Expand All @@ -80,6 +80,8 @@ export default function (storeId, storageKey = _key, localStorage = _storage) {
}
if (data && Array.isArray(data.items)) {
self.data = data
// add each item one by one to fix it if needed
data.items.forEach(item => self.addItem(item))
}
}
}
Expand Down

0 comments on commit 874b000

Please # to comment.