From 75099da69546962b705bf574b2489a05b37e956b Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Mon, 16 Aug 2021 19:31:52 +0200 Subject: [PATCH] Add css attribute name hyphenation --- css.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/css.js b/css.js index 9ee9ed0..928849d 100644 --- a/css.js +++ b/css.js @@ -3,6 +3,8 @@ const diversify = (prefix, now, ...rest) => ? now.split(/, */g).map(current => diversify(prefix+' '+current, ...rest)).join(",") : prefix +const keyToPropName = key => key.replace(/^[A-Z]/, a => "-"+a).replace(/[A-Z]/g, a => '-'+a.toLowerCase()) + const walkStyles = (styles, trail=[], buffer=[]) => { let inner const position = buffer.push(undefined)-1 @@ -16,7 +18,7 @@ const walkStyles = (styles, trail=[], buffer=[]) => { const rules = Array.isArray(children) ? children.map(e => Array.isArray(e) ? e.map(e => e.toString()).join(' ') : e.toString()).join(", ") : children.toString() - inner.push(`${name}: ${children}`) + inner.push(`${keyToPropName(name)}: ${children}`) } }) if (inner) buffer[position] = (`${diversify("", ...trail)} {${inner.join("; ")}}`)