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(",")
|
? now.split(/, */g).map(current => diversify(prefix+' '+current, ...rest)).join(",")
|
||||||
: prefix
|
: prefix
|
||||||
|
|
||||||
|
const keyToPropName = key => key.replace(/^[A-Z]/, a => "-"+a).replace(/[A-Z]/g, a => '-'+a.toLowerCase())
|
||||||
|
|
||||||
const walkStyles = (styles, trail=[], buffer=[]) => {
|
const walkStyles = (styles, trail=[], buffer=[]) => {
|
||||||
let inner
|
let inner
|
||||||
const position = buffer.push(undefined)-1
|
const position = buffer.push(undefined)-1
|
||||||
|
@ -16,7 +18,7 @@ const walkStyles = (styles, trail=[], buffer=[]) => {
|
||||||
const rules = Array.isArray(children)
|
const rules = Array.isArray(children)
|
||||||
? children.map(e => Array.isArray(e) ? e.map(e => e.toString()).join(' ') : e.toString()).join(", ")
|
? children.map(e => Array.isArray(e) ? e.map(e => e.toString()).join(' ') : e.toString()).join(", ")
|
||||||
: children.toString()
|
: children.toString()
|
||||||
inner.push(`${name}: ${children}`)
|
inner.push(`${keyToPropName(name)}: ${children}`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (inner) buffer[position] = (`${diversify("", ...trail)} {${inner.join("; ")}}`)
|
if (inner) buffer[position] = (`${diversify("", ...trail)} {${inner.join("; ")}}`)
|
||||||
|
|
Loading…
Reference in a new issue