From 9aad06602fe6b0563091ffd895757857d1f6a7e2 Mon Sep 17 00:00:00 2001 From: Gias Kay Lee Date: Fri, 9 Aug 2013 15:44:25 +0800 Subject: [PATCH] Fix #6: using `$window.addEventListener` to avoid the jQuery-specific `event.originalEvent` --- ngStorage.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ngStorage.js b/ngStorage.js index 0f25db1..3ee9d4e 100644 --- a/ngStorage.js +++ b/ngStorage.js @@ -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))); } @@ -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)];