From e507252841113dc921e7483140e0d8ab3a212b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez=20Jim=C3=A9nez?= Date: Sat, 26 Feb 2022 17:32:17 +0100 Subject: [PATCH] chore: svg on css requires svg and xlink namespaces --- packages/utils/src/svg/encode-svg-for-css.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/utils/src/svg/encode-svg-for-css.ts b/packages/utils/src/svg/encode-svg-for-css.ts index 8ddabe9..845e549 100644 --- a/packages/utils/src/svg/encode-svg-for-css.ts +++ b/packages/utils/src/svg/encode-svg-for-css.ts @@ -1,10 +1,17 @@ // https://bl.ocks.org/jennyknuth/222825e315d45a738ed9d6e04c7a88d0 export function encodeSvgForCss(svg: string): string { - return svg.replace(/"/g, '\'') + let useSvg = svg.startsWith('') ? svg.replace('', '') : svg; + if (!useSvg.includes(' xmlns:xlink=') && useSvg.includes(' xlink:')) { + useSvg = useSvg.replace('/g, '%3E') + .replace(/>/g, '%3E'); }