aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChirayu Krishnappa2013-07-23 17:19:56 -0700
committerChirayu Krishnappa2013-07-23 17:19:56 -0700
commit0a3ec5f8bbc1b51c9188f661df1697cc6a32c6a5 (patch)
treeff50d5c1540ce9b3ecd7092c1ca587808a013d17 /src
parent7e49d37a982bea6d0e323c1f7655a54d5956311a (diff)
downloadangular.js-0a3ec5f8bbc1b51c9188f661df1697cc6a32c6a5.tar.bz2
fix($$urlUtils): use document instead of $document
Diffstat (limited to 'src')
-rw-r--r--src/ng/urlUtils.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/ng/urlUtils.js b/src/ng/urlUtils.js
index c867bc89..5402b500 100644
--- a/src/ng/urlUtils.js
+++ b/src/ng/urlUtils.js
@@ -1,13 +1,15 @@
'use strict';
function $$UrlUtilsProvider() {
- this.$get = ['$document', function($document) {
- var urlParsingNode = $document[0].createElement("a"),
- // NOTE: The usage of window instead of $window here is deliberate. When the browser
- // resolves a URL for XHR, it doesn't know about any mocked $window. $$urlUtils
- // resolves URLs just as the browser would. Using $window here would confuse the
- // isSameOrigin check causing unexpected failures. We avoid that by using the real window
- // object.
+ this.$get = [function() {
+ var urlParsingNode = document.createElement("a"),
+ // NOTE: The usage of window and document instead of $window and $document here is
+ // deliberate. This service depends on the specific behavior of anchor nodes created by the
+ // browser (resolving and parsing URLs) that is unlikely to be provided by mock objects and
+ // cause us to break tests. In addition, when the browser resolves a URL for XHR, it
+ // doesn't know about mocked locations and resolves URLs to the real document - which is
+ // exactly the behavior needed here. There is little value is mocking these our for this
+ // service.
originUrl = resolve(window.location.href, true);
/**