From 7ac1e52905067de90c3463dd096980d15b143ca8 Mon Sep 17 00:00:00 2001 From: Beshoy Girgis Date: Mon, 30 Jun 2014 16:32:30 -0500 Subject: [PATCH] Check for document being in [0] key of $document I have a factory that calls localStorageService.cookie.clearAll() which throws an error of `TypeError: Cannot read property 'split' of undefined`. It turns out that this error is caused by $document having document be in `$document[0]`. The proposed update solves my issue; thanks! --- angular-local-storage.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/angular-local-storage.js b/angular-local-storage.js index 0a8ee3f..2eed36b 100644 --- a/angular-local-storage.js +++ b/angular-local-storage.js @@ -75,6 +75,8 @@ angularLocalStorage.provider('localStorageService', function() { // When Angular's $document is not available if (!$document) { $document = document; + } else if ($document[0]) { + $document = $document[0]; } // If there is a prefix set in the config lets use that with an appended period for readability