Skip to content

Commit 8129bd8

Browse files
committed
fix(svg): fix assigning style attribute does not work when CSP is enforced
1 parent 1e27245 commit 8129bd8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/svg/patch.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function removeVnodes(parentElm: Node, vnodes: SVGVNode[], startIdx: number, end
122122

123123
export function updateAttrs(oldVnode: SVGVNode, vnode: SVGVNode): void {
124124
let key: string;
125-
const elm = vnode.elm as Element;
125+
const elm = vnode.elm as SVGElement;
126126
const oldAttrs = oldVnode && oldVnode.attrs || {};
127127
const attrs = vnode.attrs || {};
128128

@@ -143,7 +143,10 @@ export function updateAttrs(oldVnode: SVGVNode, vnode: SVGVNode): void {
143143
elm.removeAttribute(key);
144144
}
145145
else {
146-
if (key.charCodeAt(0) !== xChar) {
146+
if (key === 'style') {
147+
elm.style.cssText = cur as string
148+
}
149+
else if (key.charCodeAt(0) !== xChar) {
147150
elm.setAttribute(key, cur as any);
148151
}
149152
// TODO

0 commit comments

Comments
 (0)