Skip to content

Commit 07c9c87

Browse files
committed
fix($location): don't rewrite when link is shift-clicked
Closes angular#9904
1 parent 0f7bcfd commit 07c9c87

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/ng/location.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ function $LocationProvider() {
776776
// TODO(vojta): rewrite link when opening in new tab/window (in legacy browser)
777777
// currently we open nice url link and redirect then
778778

779-
if (!html5Mode.rewriteLinks || event.ctrlKey || event.metaKey || event.which == 2) return;
779+
if (!html5Mode.rewriteLinks || event.ctrlKey || event.metaKey || event.shiftKey || event.which == 2) return;
780780

781781
var elm = jqLite(event.target);
782782

test/ng/locationSpec.js

+13
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,19 @@ describe('$location', function() {
14711471
});
14721472

14731473

1474+
it('should not rewrite when clicked with shift pressed', function() {
1475+
configureService({linkHref: 'base/a?b=c', html5Mode: true, supportHist: true});
1476+
inject(
1477+
initBrowser(),
1478+
initLocation(),
1479+
function($browser) {
1480+
browserTrigger(link, 'click', { keys: ['shift'] });
1481+
expectNoRewrite($browser);
1482+
}
1483+
);
1484+
});
1485+
1486+
14741487
it('should not mess up hash urls when clicking on links in hashbang mode', function() {
14751488
var base;
14761489
module(function() {

0 commit comments

Comments
 (0)