From 092c3bd52c627108e7f3af30f23ea09259741795 Mon Sep 17 00:00:00 2001 From: Mark MacKay Date: Wed, 2 Jun 2021 18:45:16 -0500 Subject: [PATCH] setting attribute namespace --- src/js/svgcanvas.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/js/svgcanvas.js b/src/js/svgcanvas.js index f7a2a26..63f8ff4 100644 --- a/src/js/svgcanvas.js +++ b/src/js/svgcanvas.js @@ -5830,7 +5830,6 @@ this.setSvgString = function(xmlString) { if (!href) return; const path = svgcontent.querySelector(href); const offset = el.getAttribute("startOffset"); - el.setAttribute("xml:space", "default"); // convert percentage based to absolute if (offset.includes("%") && path) { const totalLength = path.getTotalLength(); @@ -5839,7 +5838,9 @@ this.setSvgString = function(xmlString) { } const tspan = el.querySelector("tspan"); const text = el.closest("text"); + text.setAttributeNS(xmlns, "xml:space", "default"); if (tspan && text) { + // grab the first tspan and apply it to the text element svgedit.sanitize.svgWhiteList()["text"].forEach(attr => { const value = tspan.getAttribute(attr); @@ -5848,6 +5849,7 @@ this.setSvgString = function(xmlString) { text.setAttribute(attr, value); } }); + tspan.setAttributeNS(xmlns, "xml:space", "preserve"); } }) @@ -7525,7 +7527,7 @@ this.textPath = function(){ text.setAttribute("text-anchor", "middle"); text.setAttribute("x", 0); text.setAttribute("y", 0); - textPath.setAttribute("xml:space", "default"); + textPath.setAttributeNS(xmlns, "xml:space", "default"); textPath.setAttribute("xlink:href", "#" + path.id); textPath.setAttribute("href", "#" + path.id); const offset = (path.getTotalLength()/2).toFixed(0)