From e7d640b62b2a893c7148b2fd6a4e4933c26c3cfd Mon Sep 17 00:00:00 2001 From: T Morehouse Date: Sat, 1 Jun 2019 19:19:07 -0300 Subject: [PATCH] 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 --- src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index c05c450..72657e1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,6 +3,7 @@ import { VNodeData } from "vue"; const pattern = { camel: /-(\w)/g, style: /:(.*)/, + styleList: /;(?![^(]*\))/g, } as const; function camelReplace(_substr: string, match: string) { @@ -16,7 +17,7 @@ function camelCase(str: string) { function parseStyle(style: string) { let styleMap: Record = {}; - for (let s of style.split(";")) { + for (let s of style.split(pattern.styleList)) { let [key, val] = s.split(pattern.style); key = key.trim(); if (!key) {