Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(svg): fix assigning style attribute does not work when CSP is enforced #1030

Merged
merged 1 commit into from Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/svg/patch.ts
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