Skip to content

Commit f41fec2

Browse files
authored
fix[vc-util]: styleObjectToString filter invalid value (#7642)
1 parent 9118d6c commit f41fec2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

components/vc-util/Dom/css.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,13 @@ export function styleToString(style: CSSStyleDeclaration) {
121121
}
122122

123123
export function styleObjectToString(style: Record<string, string>) {
124-
return Object.keys(style)
125-
.map(name => `${name}: ${style[name]};`)
126-
.join('');
124+
return Object.keys(style).reduce((acc, name) => {
125+
const styleValue = style[name];
126+
if (typeof styleValue === 'undefined' || styleValue === null) {
127+
return acc;
128+
}
129+
130+
acc += `${name}: ${style[name]};`;
131+
return acc;
132+
}, '');
127133
}

0 commit comments

Comments
 (0)