8000 fix($$urlUtils): use document instead of $document · angular/angular.js@0a3ec5f · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 0a3ec5f

Browse files
committed
fix($$urlUtils): use document instead of $document
1 parent 7e49d37 commit 0a3ec5f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/ng/urlUtils.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
'use strict';
22

33
function $$UrlUtilsProvider() {
4-
this.$get = ['$document', function($document) {
5-
var urlParsingNode = $document[0].createElement("a"),
6-
// NOTE: The usage of window instead of $window here is deliberate. When the browser
7-
// resolves a URL for XHR, it doesn't know about any mocked $window. $$urlUtils
8-
// resolves URLs just as the browser would. Using $window here would confuse the
9-
// isSameOrigin check causing unexpected failures. We avoid that by using the real window
10-
// object.
4+
this.$get = [function() {
5+
var urlParsingNode = document.createElement("a"),
6+
// NOTE: The usage of window and document instead of $window and $document here is
7+
// deliberate. This service depends on the specific behavior of anchor nodes created by the
8+
// browser (resolving and parsing URLs) that is unlikely to be provided by mock objects and
9+
// cause us to break tests. In addition, when the browser resolves a URL for XHR, it
10+
// doesn't know about mocked locations and resolves URLs to the real document - which is
11+
// exactly the behavior needed here. There is little value is mocking these our for this
12+
// service.
1113
originUrl = resolve(window.location.href, true);
1214

1315
/**

0 commit comments

Comments
 (0)
0