Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix($$urlUtils): use document instead of $document
Browse files Browse the repository at this point in the history
  • Loading branch information
chirayuk committed Jul 24, 2013
1 parent 7e49d37 commit 0a3ec5f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/ng/urlUtils.js
Original file line number Diff line number Diff line change
@@ -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);

/**
Expand Down

0 comments on commit 0a3ec5f

Please sign in to comment.