scotttrinh / angular-localForage

Angular service & directive for https://github.com/mozilla/localForage (Offline storage, improved.)
MIT License
651 stars 86 forks source link

fix: If there is no root, use angular from window #104

Closed Menardi closed 8 years ago

Menardi commented 8 years ago

After using this with webpack, I was getting a "Cannot read angular of undefined" error when loading it in browser.

This small change checks if root is defined before trying to then access root.angular, otherwise falling back to window.angular.

As a side note, this logic is pretty much the same as before. It doesn't check if window exists before trying to access window.angular, but this check is unnecessary. In the previous code, if both root.angular and window were undefined, then angular would be undefined, quickly causing an error.

EDIT: I ran the tests locally and all passed - it looks like there may be an issue with the CI server

scotttrinh commented 8 years ago

LGTM

I'll get it merged into the new release by next weekend, thanks for the PR!