Skip to content

Commit e7d640b

Browse files
tmorehousealexsasharegan
authored andcommitted
feat: vue compliant style string parsing (#9)
Minor change based on Vue's own style parser https://github.com/vuejs/vue/blob/dev/src/platforms/web/util/style.js#L5-L16
1 parent f66248b commit e7d640b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { VNodeData } from "vue";
33
const pattern = {
44
camel: /-(\w)/g,
55
style: /:(.*)/,
6+
styleList: /;(?![^(]*\))/g,
67
} as const;
78

89
function camelReplace(_substr: string, match: string) {
@@ -16,7 +17,7 @@ function camelCase(str: string) {
1617
function parseStyle(style: string) {
1718
let styleMap: Record<string, any> = {};
1819

19-
for (let s of style.split(";")) {
20+
for (let s of style.split(pattern.styleList)) {
2021
let [key, val] = s.split(pattern.style);
2122
key = key.trim();
2223
if (!key) {

0 commit comments

Comments
 (0)