4
This README is automatically generated from the comments in these files:
7
Edit those files, and our readme bot will duplicate them over here!
8
Edit this file, and the bot will squash your changes :)
12
[![Build Status](https://travis-ci.org/PolymerElements/iron-localstorage.svg?branch=master)](https://travis-ci.org/PolymerElements/iron-localstorage)
14
_[Demo and API Docs](https://elements.polymer-project.org/elements/iron-localstorage)_
17
##<iron-localstorage>
20
Element access to Web Storage API (window.localStorage).
22
Keeps `value` property in sync with localStorage.
24
Value is saved as json by default.
28
`ls-sample` will automatically save changes to its value.
30
<dom-module id="ls-sample">
31
<iron-localstorage name="my-app-storage"
33
on-iron-localstorage-load-empty="initializeDefaultCartoon"
45
// initializes default if nothing has been stored
46
initializeDefaultCartoon: function() {
52
// use path set api to propagate changes to localstorage
53
makeModifications: function() {
54
this.set('cartoon.name', "Minions");
55
this.set('cartoon.hasEars', false);
62
* `value.*` is observed, and saved on modifications. You must use
63
path change notifification methods such as `set()` to modify value
64
for changes to be observed.
66
* Set `auto-save-disabled` to prevent automatic saving.
68
* Value is saved as JSON by default.
70
* To delete a key, set value to null
72
Element listens to StorageAPI `storage` event, and will reload upon receiving it.
74
**Warning**: do not bind value to sub-properties until Polymer
75
[bug 1550](https://github.com/Polymer/polymer/issues/1550)
76
is resolved. Local storage will be blown away.
77
`<iron-localstorage value="{{foo.bar}}"` will cause **data loss**.