Skip to content

Commit

Permalink
fix($StateRefDirective): resolve missing support for xlink:href angul…
Browse files Browse the repository at this point in the history
…ar-ui#1667

Set the correct attribute when dealing with an SVG anchor element.
Otherwise, angular will prevent the click.
  • Loading branch information
martinoss committed Jan 3, 2015
1 parent a05ee40 commit 992eaba
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/stateDirectives.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
// 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) || {};
Expand Down

0 comments on commit 992eaba

Please sign in to comment.