Skip to content

Commit

Permalink
fix(reset): fix reseting self.data (by reference)
Browse files Browse the repository at this point in the history
  • Loading branch information
leomp12 committed Jan 25, 2020
1 parent 16f31e4 commit 548de25
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/methods/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ ecomCart.reset()
*/

export default (self, emitter, [canSave = true]) => {
let { data, save } = self

data = {
self.data = {
_id: randomObjectId(),
items: [],
subtotal: 0
Expand All @@ -30,10 +28,12 @@ export default (self, emitter, [canSave = true]) => {
* @property {object} data - Shopping cart data
* @example ecomCart.on('reset', ({ data }) => { console.log(data._id) })
*/
emitter.emit('reset', { data })
emitter.emit('reset', {
data: self.data
})

if (canSave) {
save(false)
self.save(false)
}
return self
}

0 comments on commit 548de25

Please # to comment.