From 256c529de8a3743e388d9de40ef43a09e1e8eb80 Mon Sep 17 00:00:00 2001 From: whyzdev Date: Sun, 1 Jan 2017 22:46:08 -0500 Subject: [PATCH] fix cli css style selector text lowercase problem by setting svg style content to commandline css content, if available -- this overwrites cloneCssStyles --- lib/phantomscript.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/phantomscript.js b/lib/phantomscript.js index 12a73c625..8e2a26f7a 100644 --- a/lib/phantomscript.js +++ b/lib/phantomscript.js @@ -90,8 +90,9 @@ files.forEach(function(file) { }) oDOM = oParser.parseFromString(svgContent, "text/xml") - + resolveSVGElement(oDOM.firstChild) + setSVGStyle(oDOM.firstChild, options.css) // traverse the SVG, and replace all foreignObject elements // can be removed when https://github.com/knsv/mermaid/issues/58 is resolved @@ -184,6 +185,13 @@ function resolveSVGElement(element) { } } +function setSVGStyle(svg, css) { + if (!css || !svg) {return} + var styles=svg.getElementsByTagName('style'); + if (!styles || styles.length==0) { return } + styles[0].textContent = css; +} + function resolveForeignObjects(element) { return; var children