Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(a): don't preventDefault on click when SVGAElement has an xlink:href attribute #5897

Closed
wants to merge 1 commit into from

Conversation

caitp
Copy link
Contributor

@caitp caitp commented Jan 20, 2014

Before this change, an SVGAElement with an xlink:href attribute and no href or name attribute which was compiled by the angular HTML compiler would never be clickable, due to the htmlAnchorDirective calling event.preventDefault() due to the missing href attribute.

This change corrects this behaviour by also testing the xlink:href attribute if the element in question is determined to be an SVG anchor tag (with the href property having type SVGAnimatedString)


Some proper E2E testing would test this fix much more effectively.

This is demonstrated to be working here (edit here, but the link won't work within the iframe, only outside it)
Closes #5896

@@ -32,11 +32,14 @@ var htmlAnchorDirective = valueFn({
element.append(document.createComment('IE fix'));
}

if (!attr.href && !attr.name) {
if (!attr.href && !attr.xlinkHref && !attr.name) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why exactly do we care about the 'name' attribute? I don't really get that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it has name then it's just an anchor e.g. <a name="someId"></a> and in that case we don't need to listen for clicks on this element.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I see, thanks

…ref attribute

Before this change, an SVGAElement with an xlink:href attribute and no href or name attribute which
was compiled by the angular HTML compiler would never be clickable, due to the htmlAnchorDirective
calling event.preventDefault() due to the missing href attribute.

This change corrects this behaviour by also testing the xlink:href attribute if the element in
question is determined to be an SVG anchor tag (with the href property having type SVGAnimatedString)

Closes angular#5896
@IgorMinar
Copy link
Contributor

lgtm

@caitp caitp closed this in e020916 Jan 22, 2014
@caitp caitp deleted the issue-5896 branch January 22, 2014 19:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Svg link don't work even if there is no angular var inside
2 participants