From 9b85757102fbd44e88d0a3909fdf8b90f191b593 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Thu, 20 Oct 2011 08:46:09 -0700 Subject: fix($location): rewrite links with nested elements For example: inner text If you click on "text", then the span element is event.target, so we need to traverse the DOM. --- test/service/locationSpec.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/service/locationSpec.js b/test/service/locationSpec.js index 6cf302fe..9a7aa943 100644 --- a/test/service/locationSpec.js +++ b/test/service/locationSpec.js @@ -556,10 +556,11 @@ describe('$location', function() { var root, link, extLink, $browser, originalBrowser, lastEventPreventDefault; - function init(linkHref, html5Mode, supportHist, attrs) { + function init(linkHref, html5Mode, supportHist, attrs, content) { var jqRoot = jqLite('
'); attrs = attrs ? ' ' + attrs + ' ' : ''; - link = jqLite('link')[0]; + content = content || 'link'; + link = jqLite('' + content + '')[0]; root = jqRoot.append(link)[0]; jqLite(document.body).append(jqRoot); @@ -670,6 +671,15 @@ describe('$location', function() { }); + it('should rewrite when clicked span inside link', function() { + init('some/link', true, true, '', 'link'); + var span = jqLite(link).find('span'); + + browserTrigger(span, 'click'); + expectRewriteTo('http://host.com/base/some/link'); + }); + + // don't run next tests on IE<9, as browserTrigger does not simulate pressed keys if (!(msie < 9)) { -- cgit v1.2.3