Closed danharper closed 12 years ago
It's correct remark, thanks. The mistake is here:
clear: ->
# ...
this.setItem(@name, '')
I think we should fix this behavior in the next version.
I've tried removing that line, yet this still happens.
tasks.storage.clear()
tasks.storage.getItem('tasks')
# returns '' (empty string)
I've tried debugging, like so:
clear: ->
keys = Object.keys(localStorage)
collectionKeys = _.filter keys, (key) => (new RegExp @name).test(key)
this.removeItem(key) for key in collectionKeys
# this.setItem(@name, '')
console.log 'before reset', this.getItem(@name)
record.reset() for record in [@allIds, @destroyIds]
console.log 'after reset', this.getItem(@name)
# CONSOLE:
# => before reset, null
# => after reset, ''
:\
I'll try to figure out with it tomorrow.
Just noticed you fixed this, thank you :)
I have a collection 'tasks' with a storage key of 'tasks'.
Surely
tasks.storage.getItem('tasks')
should returnnull
?I can't seem to make it so
clear()
removes the 'tasks' key. It always seems to be reset to an empty string.It seems like the unit test:
Should actually be:
Any help with this? Or is
clear()
not supposed to empty the whole collection from storage? If you could point me in the right direction I could submit a pull request?