From 2be590ab24a74616326edae14f25d8b8e23ea4d5 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Sun, 13 Jun 2021 12:10:59 +0300 Subject: [PATCH] replace href with xlink:href in saved image --- modules/save.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/save.js b/modules/save.js index 82564489..1a2e910d 100644 --- a/modules/save.js +++ b/modules/save.js @@ -184,14 +184,23 @@ async function getMapURL(type, subtype) { if (pattern) cloneDefs.appendChild(pattern.cloneNode(true)); } - if (!cloneEl.getElementById("hatching").children.length) cloneEl.getElementById("hatching").remove(); //remove unused hatching group - if (!cloneEl.getElementById("fogging-cont")) cloneEl.getElementById("fog").remove(); //remove unused fog + if (!cloneEl.getElementById("hatching").children.length) cloneEl.getElementById("hatching").remove(); // remove unused hatching group + if (!cloneEl.getElementById("fogging-cont")) cloneEl.getElementById("fog").remove(); // remove unused fog if (!cloneEl.getElementById("regions")) cloneEl.getElementById("statePaths").remove(); // removed unused statePaths if (!cloneEl.getElementById("labels")) cloneEl.getElementById("textPaths").remove(); // removed unused textPaths // add armies style if (cloneEl.getElementById("armies")) cloneEl.insertAdjacentHTML("afterbegin", ""); + // add xlink: for href to support svg1.1 + if (type === "svg") { + cloneEl.querySelectorAll("[href]").forEach(el => { + const href = el.getAttribute("href"); + el.removeAttribute("href"); + el.setAttribute("xlink:href", href); + }); + } + const fontStyle = await GFontToDataURI(getFontsToLoad(clone)); // load non-standard fonts if (fontStyle) clone.select("defs").append("style").text(fontStyle.join("\n")); // add font to style clone.remove();