bug in iron-localstorage

138 views
Skip to first unread message

Kyle Maxwell

unread,
Jul 28, 2015, 2:03:09 PM7/28/15
to Polymer
Hi, I wanted to check in here about an issue I am having, that may be a bug. I am updating an element from Polymer 0.5 core-localstorage to 1.0 iron-localstorage. I noticed one inconsistency related to the fact that localStorage.getItem returns null when an item doesn't exist. This was handled appropriately in core-localstorage, but in iron-localstorage, the value is explicitly set to null, when localStorage is empty. This means on the first load of my element everything that is using local storage is set to null, which causes some number of problems. I wanted to see if this logic is sound, before creating an issue on github.
Thanks,
Kyle

Line 186: 
this.value = null;
...

Explained on line 90:
// localStorage has a flaw that makes it difficult to determine
...

Aleks Totic

unread,
Jul 30, 2015, 10:46:05 AM7/30/15
to Polymer, ky...@flux.io
The initialization has changed. If you'd like to initialize value to a default when empty, use 'iron-localstorage-load-empty' event handler.

Aleks

Kyle Maxwell

unread,
Jul 30, 2015, 1:49:07 PM7/30/15
to Aleks Totic, Polymer
Thanks for the workaround, that works! I missed that while looking at the code.
-kyle
Reply all
Reply to author
Forward
0 new messages