aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVojta Jina2011-10-20 08:46:09 -0700
committerIgor Minar2011-10-22 15:35:18 -0700
commit9b85757102fbd44e88d0a3909fdf8b90f191b593 (patch)
tree88eb638ba4b91e51ef9e4a1315aa357de22ae02a /src
parentc6c3949b14f4003ecab291243edfca61262f2c3d (diff)
downloadangular.js-9b85757102fbd44e88d0a3909fdf8b90f191b593.tar.bz2
fix($location): rewrite links with nested elements
For example: <a href="some/link">inner <span>text</span></a> If you click on "text", then the span element is event.target, so we need to traverse the DOM.
Diffstat (limited to 'src')
-rw-r--r--src/service/location.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/service/location.js b/src/service/location.js
index 2ffc5587..d1d34e67 100644
--- a/src/service/location.js
+++ b/src/service/location.js
@@ -442,12 +442,16 @@ angularServiceInject('$location', function($browser, $sniffer, $locationConfig,
// TODO(vojta): rewrite link when opening in new tab/window (in legacy browser)
// currently we open nice url link and redirect then
- if (uppercase(event.target.nodeName) != 'A' || event.ctrlKey || event.metaKey ||
- event.which == 2) return;
+ if (event.ctrlKey || event.metaKey || event.which == 2) return;
- var elm = jqLite(event.target),
- href = elm.attr('href');
+ var elm = jqLite(event.target);
+ // traverse the DOM up to find first A tag
+ while (elm.length && lowercase(elm[0].nodeName) !== 'a') {
+ elm = elm.parent();
+ }
+
+ var href = elm.attr('href');
if (!href || isDefined(elm.attr('ng:ext-link')) || elm.attr('target')) return;
// remove same domain from full url links (IE7 always returns full hrefs)