Browse Source

fix[vc-util]: styleObjectToString filter invalid value (#7642)

pull/7648/head
Carl Chen 6 months ago committed by GitHub
parent
commit
f41fec26ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      components/vc-util/Dom/css.ts

12
components/vc-util/Dom/css.ts

@ -121,7 +121,13 @@ export function styleToString(style: CSSStyleDeclaration) {
} }
export function styleObjectToString(style: Record<string, string>) { export function styleObjectToString(style: Record<string, string>) {
return Object.keys(style) return Object.keys(style).reduce((acc, name) => {
.map(name => `${name}: ${style[name]};`) const styleValue = style[name];
.join(''); if (typeof styleValue === 'undefined' || styleValue === null) {
return acc;
}
acc += `${name}: ${style[name]};`;
return acc;
}, '');
} }

Loading…
Cancel
Save