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
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