Skip to content

Commit

Permalink
Fix #11: Prevent an error on IE8 which doesn't support `addEventListe…
Browse files Browse the repository at this point in the history
…ner()`
  • Loading branch information
Gias Kay Lee committed Oct 15, 2013
1 parent cfc0e4e commit 2f36c9c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 deletions ngStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
){
// #9: Assign a placeholder object if Web Storage is unavailable to prevent breaking the entire AngularJS app
var webStorage = $window[storageType] || (console.warn('This browser does not support Web Storage!'), {}),

$storage = {
$default: function(items) {
for (var k in items) {
Expand All @@ -55,9 +54,7 @@
return $storage.$default(items);
}
},

_last$storage,

_debounce;

for (var i = 0, k; i < webStorage.length; i++) {
Expand Down Expand Up @@ -88,7 +85,7 @@
});

// #6: Use `$window.addEventListener` instead of `angular.element` to avoid the jQuery-specific `event.originalEvent`
'localStorage' === storageType && $window.addEventListener('storage', function(event) {
'localStorage' === storageType && $window.addEventListener && $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
4 changes: 2 additions & 2 deletions ngStorage.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2f36c9c

Please sign in to comment.