From 8129bd84fe0c76731cf95d7db8e744fe5b1118f3 Mon Sep 17 00:00:00 2001 From: Aleksandr Lesnenko Date: Mon, 18 Sep 2023 16:15:08 -0300 Subject: [PATCH] fix(svg): fix assigning style attribute does not work when CSP is enforced --- src/svg/patch.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/svg/patch.ts b/src/svg/patch.ts index aeba565c8..edea6ae86 100644 --- a/src/svg/patch.ts +++ b/src/svg/patch.ts @@ -122,7 +122,7 @@ function removeVnodes(parentElm: Node, vnodes: SVGVNode[], startIdx: number, end export function updateAttrs(oldVnode: SVGVNode, vnode: SVGVNode): void { let key: string; - const elm = vnode.elm as Element; + const elm = vnode.elm as SVGElement; const oldAttrs = oldVnode && oldVnode.attrs || {}; const attrs = vnode.attrs || {}; @@ -143,7 +143,10 @@ export function updateAttrs(oldVnode: SVGVNode, vnode: SVGVNode): void { elm.removeAttribute(key); } else { - if (key.charCodeAt(0) !== xChar) { + if (key === 'style') { + elm.style.cssText = cur as string + } + else if (key.charCodeAt(0) !== xChar) { elm.setAttribute(key, cur as any); } // TODO