From 0149a7bb38b7af99388a1ad7cc9909a7b7c4439d Mon Sep 17 00:00:00 2001 From: Martin Oss Date: Sat, 3 Jan 2015 14:43:39 +0100 Subject: [PATCH] fix($StateRefDirective): resolve missing support for svg anchor elements #1667 --- src/stateDirectives.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/stateDirectives.js b/src/stateDirectives.js index 4d9d527dd..34dfc1a9f 100644 --- a/src/stateDirectives.js +++ b/src/stateDirectives.js @@ -86,9 +86,12 @@ function $StateRefDirective($state, $timeout) { link: function(scope, element, attrs, uiSrefActive) { var ref = parseStateRef(attrs.uiSref, $state.current.name); var params = null, url = null, base = stateContext(element) || $state.$current; - var newHref = null, isAnchor = element.prop("tagName") === "A"; + // SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute. + var hrefKind = toString.call(element.prop('href')) === '[object SVGAnimatedString]' ? + 'xlink:href' : 'href'; + var newHref = null, isAnchor = element.prop("tagName").toUpperCase() === "A"; var isForm = element[0].nodeName === "FORM"; - var attr = isForm ? "action" : "href", nav = true; + var attr = isForm ? "action" : hrefKind, nav = true; var options = { relative: base, inherit: true }; var optionsOverride = scope.$eval(attrs.uiSrefOpts) || {};