Skip to content

Commit f3a6b65

Browse files
lancelifwh1990
authored andcommitted
feat: Convert attribute name to camel case, e.g fill-opacity to fillOpacity
1 parent ef7a72f commit f3a6b65

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libs/generateComponent.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,10 @@ const addAttribute = (domName: string, sub: XmlData['svg']['symbol'][number]['pa
172172
template += `\n${whitespace(counter.baseIdent + 4)}${attributeName}={getIconColor(color, ${counter.colorIndex}, '${sub.$[attributeName]}')}`;
173173
counter.colorIndex += 1;
174174
} else {
175-
template += `\n${whitespace(counter.baseIdent + 4)}${attributeName}="${sub.$[attributeName]}"`;
175+
// convert attribute name to camel case, e.g fill-opacity to fillOpacity
176+
const reg = /-(\w)/g;
177+
const camelAttributeName = attributeName.replace(reg, (a,b) => b.toUpperCase());
178+
template += `\n${whitespace(counter.baseIdent + 4)}${camelAttributeName}="${sub.$[attributeName]}"`;
176179
}
177180
}
178181
}

0 commit comments

Comments
 (0)