Skip to content

Commit

Permalink
Merge pull request #1030 from alxnddr/fix-csp-issue
Browse files Browse the repository at this point in the history
fix(svg): fix assigning style attribute does not work when CSP is enforced
  • Loading branch information
plainheart authored Sep 22, 2023
2 parents 1e27245 + 8129bd8 commit 9263428
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/svg/patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {};

Expand All @@ -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
Expand Down

0 comments on commit 9263428

Please sign in to comment.