Skip to content

Commit 7ac1e52

Browse files
committed
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!
1 parent d08649f commit 7ac1e52

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

angular-local-storage.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ angularLocalStorage.provider('localStorageService', function() {
7575
// When Angular's $document is not available
7676
if (!$document) {
7777
$document = document;
78+
} else if ($document[0]) {
79+
$document = $document[0];
7880
}
7981

8082
// If there is a prefix set in the config lets use that with an appended period for readability

0 commit comments

Comments
 (0)