Clicking on an svg link:

<a xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/foo/bar/test">
  <polygon points="...."></polygon>
</a>

gives me:

Uncaught TypeError: this.href.match is not a function

on:

else if (Drupal.settings.googleanalytics.trackOutbound && this.href.match(/^\w+:\/\//i)) {

that's because the this.href is of type SVGAnimatedString instead of a link

Comments

hass’s picture

Title: tracking on svg link fails » Track svg links
Version: 7.x-2.1 » 8.x-2.x-dev
Category: Bug report » Feature request
ioannis.cherouvim’s picture

Version: 8.x-2.x-dev » 7.x-2.x-dev
ioannis.cherouvim’s picture

To solve this you can go to line 13 and add:

var href = this.getAttribute('href')||this.getAttribute('xlink:href');

and replace all occurences of this.href with href.

hass’s picture

Version: 7.x-2.x-dev » 8.x-2.x-dev

What happens if both do not exist?

ioannis.cherouvim’s picture

The value of href will be null. My proposed change doesn't affect anything in this regard. It just allows the code to work with both html a and svg a elements.

If there are more clickable html/svg stuff with target hrefs (I don't know any other than html a and svg a) then we could add it.

hass’s picture

Status: Active » Closed (won't fix)

https://developer.mozilla.org/de/docs/Web/SVG/Attribute/xlink:href

Deprecated since SVG 2
This feature has been removed from the Web standards. Though some browsers may still support it, it is in the process of being dropped. Avoid using it and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

And:

Note: SVG 2 removed the need for the xlink namespace, so instead of xlink:href you should use href.

This makes this featue a won't fix. At least Firefox 51+ has this feature.