fix style attribute space (#1639)

When the svg code has some blank in style attribute,like this style="white-space: pre; "
it was throw an error Cannot read property 'trim' of undefined.
This commit is contained in:
Ollie
2022-07-26 21:20:48 +08:00
committed by GitHub
parent 0722eedf2f
commit 82717e656a

View File

@@ -205,7 +205,7 @@ export type Styles = { [property: string]: string };
export function getStyle(string: string): Styles {
const style: Styles = {};
const declarations = string.split(';');
const declarations = string.split(';').filter(v => v.trim());
const { length } = declarations;
for (let i = 0; i < length; i++) {
const declaration = declarations[i];