Add css attribute name hyphenation
This commit is contained in:
parent
8c0c4f5614
commit
75099da695
1 changed files with 3 additions and 1 deletions
4
css.js
4
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("; ")}}`)
|
||||
|
|
Loading…
Reference in a new issue