diff --git a/lib/popup.js b/lib/popup.js index a606a90..7dac9ff 100644 --- a/lib/popup.js +++ b/lib/popup.js @@ -96,6 +96,21 @@ var str = JSON.stringify(this.data || {}); localStorage.setItem(this.key, str); + }, + remove: function(key) { + if( key ) { + delete this.data[key]; + if( $.isEmptyObject(this.data) ) { + this.remove(); + } + else { + var str = JSON.stringify(this.data || {}); + localStorage.setItem(this.key, str); + } + } + else { + localStorage.removeItem(this.key); + } } }, apiclb: { @@ -218,7 +233,7 @@ }; }, removeDraft: function() { - popup.storage.set('draft', null); + popup.storage.remove('draft', null); popup.applyData(); popup.el.draftRemoveLink.addClass('is-hidden'); },