Skip to content

Commit

Permalink
Fix #6: using $window.addEventListener to avoid the jQuery-specific…
Browse files Browse the repository at this point in the history
… `event.originalEvent`
  • Loading branch information
Gias Kay Lee committed Aug 9, 2013
1 parent 1623451 commit 9aad066
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ngStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
},
_last$storage;

// #8
// (#8) `i < webStorage.length` is needed for IE9
for (var i = 0, k; i < webStorage.length && (k = webStorage.key(i)); i++) {
'ngStorage-' === k.slice(0, 10) && ($storage[k.slice(10)] = angular.fromJson(webStorage.getItem(k)));
}
Expand Down Expand Up @@ -90,7 +90,8 @@
}
});

'localStorage' === storageType && angular.element($window).bind('storage', function(event) {
// (#6) Use `$window.addEventListener` to avoid the jQuery-specific `event.originalEvent`
'localStorage' === storageType && $window.addEventListener('storage', function(event) {
if ('ngStorage-' === event.key.slice(0, 10)) {
event.newValue ? $storage[event.key.slice(10)] = angular.fromJson(event.newValue) : delete $storage[event.key.slice(10)];

Expand Down

0 comments on commit 9aad066

Please sign in to comment.