Skip to content

Commit 0149a7b

Browse files
committed
fix($StateRefDirective): resolve missing support for svg anchor elements #1667
1 parent 7e38adb commit 0149a7b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/stateDirectives.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,12 @@ function $StateRefDirective($state, $timeout) {
8686
link: function(scope, element, attrs, uiSrefActive) {
8787
var ref = parseStateRef(attrs.uiSref, $state.current.name);
8888
var params = null, url = null, base = stateContext(element) || $state.$current;
89-
var newHref = null, isAnchor = element.prop("tagName") === "A";
89+
// SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute.
90+
var hrefKind = toString.call(element.prop('href')) === '[object SVGAnimatedString]' ?
91+
'xlink:href' : 'href';
92+
var newHref = null, isAnchor = element.prop("tagName").toUpperCase() === "A";
9093
var isForm = element[0].nodeName === "FORM";
91-
var attr = isForm ? "action" : "href", nav = true;
94+
var attr = isForm ? "action" : hrefKind, nav = true;
9295

9396
var options = { relative: base, inherit: true };
9497
var optionsOverride = scope.$eval(attrs.uiSrefOpts) || {};

0 commit comments

Comments
 (0)