From 3473ccb61369606ca01312f90569805c451dbd35 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Mon, 22 Feb 2016 16:58:06 +0100 Subject: [PATCH 1/2] Use full location URL for xlink references in SVG elements when the page includes a element. Resolves issue #831. --- unpacked/jax/output/SVG/jax.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/unpacked/jax/output/SVG/jax.js b/unpacked/jax/output/SVG/jax.js index ea221f1d7..777497de6 100644 --- a/unpacked/jax/output/SVG/jax.js +++ b/unpacked/jax/output/SVG/jax.js @@ -33,6 +33,13 @@ var SVGNS = "http://www.w3.org/2000/svg"; var XLINKNS = "http://www.w3.org/1999/xlink"; + // + // Get the URL of the page (for use with xlink:href) when there + // is a element on the page. + // + var SVGURL = String(document.location).replace(/#.*$/,""); + if (document.getElementsByTagName("base").length === 0) SVGURL = ""; + SVG.Augment({ HFUZZ: 2, // adjustments for height and depth of final svg element DFUZZ: 2, // to get baselines right (fragile). @@ -1052,7 +1059,7 @@ if (cache) { def = {}; if (transform) {def.transform = transform} this.element = SVG.Element("use",def); - this.element.setAttributeNS(XLINKNS,"href","#"+id); + this.element.setAttributeNS(XLINKNS,"href",SVGURL+"#"+id); } this.h = (h+t) * scale; this.d = (d+t) * scale; this.w = (w+t/2) *scale; this.l = (l+t/2) * scale; this.r = (r+t/2) * scale; From e14a8516d77b84ce5ed015daf10688bc732928eb Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 11 May 2016 20:39:42 -0400 Subject: [PATCH 2/2] Make Volker's suggested change. Issue #831. --- unpacked/jax/output/SVG/jax.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unpacked/jax/output/SVG/jax.js b/unpacked/jax/output/SVG/jax.js index 777497de6..97eb3f343 100644 --- a/unpacked/jax/output/SVG/jax.js +++ b/unpacked/jax/output/SVG/jax.js @@ -37,8 +37,8 @@ // Get the URL of the page (for use with xlink:href) when there // is a element on the page. // - var SVGURL = String(document.location).replace(/#.*$/,""); - if (document.getElementsByTagName("base").length === 0) SVGURL = ""; + var SVGURL = (document.getElementsByTagName("base").length === 0) ? "" : + String(document.location).replace(/#.*$/,""); SVG.Augment({ HFUZZ: 2, // adjustments for height and depth of final svg element