mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 15:24:43 +00:00
fix($location): prevent navigation if already on the URL
This commit is contained in:
parent
fd21c7502f
commit
4bd7bedf48
2 changed files with 20 additions and 5 deletions
|
|
@ -528,12 +528,14 @@ function $LocationProvider(){
|
||||||
rewrittenUrl = $location.$$rewrite(absHref);
|
rewrittenUrl = $location.$$rewrite(absHref);
|
||||||
|
|
||||||
if (absHref && !elm.attr('target') && rewrittenUrl) {
|
if (absHref && !elm.attr('target') && rewrittenUrl) {
|
||||||
// update location manually
|
|
||||||
$location.$$parse(rewrittenUrl);
|
|
||||||
$rootScope.$apply();
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
// hack to work around FF6 bug 684208 when scenario runner clicks on links
|
if (rewrittenUrl != initialUrl) {
|
||||||
window.angular['ff-684208-preventDefault'] = true;
|
// update location manually
|
||||||
|
$location.$$parse(rewrittenUrl);
|
||||||
|
$rootScope.$apply();
|
||||||
|
// hack to work around FF6 bug 684208 when scenario runner clicks on links
|
||||||
|
window.angular['ff-684208-preventDefault'] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -819,6 +819,19 @@ describe('$location', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('should do nothing if already on the same URL', function() {
|
||||||
|
configureService('/base/', true, true);
|
||||||
|
inject(
|
||||||
|
initBrowser(),
|
||||||
|
initLocation(),
|
||||||
|
function($browser) {
|
||||||
|
browserTrigger(link, 'click');
|
||||||
|
expectNoRewrite($browser, 'http://host.com/base/');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should rewrite abs link to new url when history enabled on new browser', function() {
|
it('should rewrite abs link to new url when history enabled on new browser', function() {
|
||||||
configureService('/base/link?a#b', true, true);
|
configureService('/base/link?a#b', true, true);
|
||||||
inject(
|
inject(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue