-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
…cy browsers This CL fixes problems and adds test cases for changes from #6421. Changes include fixing the algorithm for preprocessing href attribute values, as well as supporting xlink:href attributes. Credit for the original URL parsing algorithm still goes to @richardcrichardc. Good work, champ!
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -779,15 +779,22 @@ describe('$location', function() { | |
|
||
var root, link, originalBrowser, lastEventPreventDefault; | ||
|
||
function configureService(linkHref, html5Mode, supportHist, attrs, content) { | ||
function configureService(linkHref, html5Mode, supportHist, relLink, attrs, content) { | ||
if (typeof relLink !== "boolean") { | ||
content = attrs; | ||
attrs = relLink; | ||
relLink = false; | ||
} | ||
module(function($provide, $locationProvider) { | ||
attrs = attrs ? ' ' + attrs + ' ' : ''; | ||
|
||
// fake the base behavior | ||
if (linkHref[0] == '/') { | ||
linkHref = 'http://host.com' + linkHref; | ||
} else if(!linkHref.match(/:\/\//)) { | ||
linkHref = 'http://host.com/base/' + linkHref; | ||
if (!relLink) { | ||
This comment has been minimized.
Sorry, something went wrong.
chrisirhc
Contributor
|
||
if (linkHref[0] == '/') { | ||
linkHref = 'http://host.com' + linkHref; | ||
} else if(!linkHref.match(/:\/\//)) { | ||
linkHref = 'http://host.com/base/' + linkHref; | ||
} | ||
} | ||
|
||
link = jqLite('<a href="' + linkHref + '"' + attrs + '>' + content + '</a>')[0]; | ||
|
@@ -1067,6 +1074,51 @@ describe('$location', function() { | |
}); | ||
|
||
|
||
it('should rewrite relative links relative to current path when history disabled', function() { | ||
configureService('link', true, false, true); | ||
inject( | ||
initBrowser(), | ||
initLocation(), | ||
function($browser, $location) { | ||
$location.path('/some'); | ||
browserTrigger(link, 'click'); | ||
expectRewriteTo($browser, 'http://host.com/base/index.html#!/some/link'); | ||
} | ||
); | ||
}); | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
tleruitte
Contributor
|
||
|
||
it('should replace current path when link begins with "/" and history disabled', function() { | ||
configureService('/link', true, false, true); | ||
inject( | ||
initBrowser(), | ||
initLocation(), | ||
function($browser, $location) { | ||
$location.path('/some'); | ||
browserTrigger(link, 'click'); | ||
expectRewriteTo($browser, 'http://host.com/base/index.html#!/link'); | ||
} | ||
); | ||
}); | ||
This comment has been minimized.
Sorry, something went wrong.
chrisirhc
Contributor
|
||
|
||
|
||
it('should replace current hash fragment when link begins with "#" history disabled', function() { | ||
configureService('#link', true, false, true); | ||
inject( | ||
initBrowser(), | ||
initLocation(), | ||
function($browser, $location) { | ||
// Initialize browser URL | ||
$location.path('/some'); | ||
$location.hash('foo'); | ||
browserTrigger(link, 'click'); | ||
expect($location.hash()).toBe('link'); | ||
expectRewriteTo($browser, 'http://host.com/base/index.html#!/some#link'); | ||
} | ||
); | ||
}); | ||
|
||
|
||
// don't run next tests on IE<9, as browserTrigger does not simulate pressed keys | ||
if (!(msie < 9)) { | ||
|
||
|
Now using 1.2.26 and change on this row breaks routing when having a base href and clicking on link in IE8 standards mode. No error is show - nothing seem to happen when click links (route is not matching).