Skip to content

Commit

Permalink
fix storage event
Browse files Browse the repository at this point in the history
  • Loading branch information
fsmanuel committed Nov 26, 2015
1 parent 5f3d803 commit 6603619
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions addon/mixins/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,21 @@ export default Mixin.create({
// Keep in sync with other windows
if (window.addEventListener) {
window.addEventListener('storage', (event) => {
if (event.key === storageKey) {
this.set('content', JSON.parse(event.newValue));
if (event.storageArea === storage && event.key === storageKey) {
if (
event.newValue === event.oldValue ||
event.newValue === JSON.stringify(this.get('content'))
) {
return;
}

if (event.newValue) {
this.set('content', JSON.parse(event.newValue));
} else {
this.clear();
}
}
});
}, false);
}

return this._super.apply(this, arguments);
Expand Down

0 comments on commit 6603619

Please # to comment.