From 07c9c87d8eab083b1ae88623e5b44340b8236fa5 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Tue, 4 Nov 2014 11:15:39 -0500 Subject: [PATCH] fix($location): don't rewrite when link is shift-clicked Closes #9904 --- src/ng/location.js | 2 +- test/ng/locationSpec.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ng/location.js b/src/ng/location.js index c315551006ac..e314f60631fb 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -776,7 +776,7 @@ function $LocationProvider() { // TODO(vojta): rewrite link when opening in new tab/window (in legacy browser) // currently we open nice url link and redirect then - if (!html5Mode.rewriteLinks || event.ctrlKey || event.metaKey || event.which == 2) return; + if (!html5Mode.rewriteLinks || event.ctrlKey || event.metaKey || event.shiftKey || event.which == 2) return; var elm = jqLite(event.target); diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js index 5a338729cf00..4b81bbf81e1d 100644 --- a/test/ng/locationSpec.js +++ b/test/ng/locationSpec.js @@ -1471,6 +1471,19 @@ describe('$location', function() { }); + it('should not rewrite when clicked with shift pressed', function() { + configureService({linkHref: 'base/a?b=c', html5Mode: true, supportHist: true}); + inject( + initBrowser(), + initLocation(), + function($browser) { + browserTrigger(link, 'click', { keys: ['shift'] }); + expectNoRewrite($browser); + } + ); + }); + + it('should not mess up hash urls when clicking on links in hashbang mode', function() { var base; module(function() {