Skip to content

Commit

Permalink
Combine isProp and isClass to common isIdenfitier
Browse files Browse the repository at this point in the history
  • Loading branch information
emilbayes authored and porsager committed Sep 14, 2020
1 parent 7394073 commit 18acd32
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import properties from './properties.js'

const doc = typeof document !== 'undefined' && window.document // eslint-disable-line
, validChar = (c, ci) => ci ? x => c.indexOf(x.toLowerCase()) > -1 : x => c.indexOf(x) > -1
, isProp = validChar('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789')
, isClass = validChar('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_', true)
, isIdentifier = validChar('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_')
, isQuote = validChar('\'"')
, isValueSep = validChar(' ,)')
, isNumber = x => typeof x === 'number'
Expand Down Expand Up @@ -164,7 +163,7 @@ export default function bss({
, name = false

for (let i = 0; i < s.length; i++) {
if (i > 0 && name && !isClass(s[i])) {
if (i > 0 && name && !isIdentifier(s[i])) {
x = s.slice(1, i) + '-' + x
name = false
}
Expand Down Expand Up @@ -266,9 +265,9 @@ export default function bss({
if (!x.value && x.prop !== null && x.out.length && v === ',') {
x.value = x.comma
x.prop = x.out[x.out.length - 1][0]
} else if (!x.value && x.prop === null && isProp(v)) {
} else if (!x.value && x.prop === null && isIdentifier(v)) {
x.prop = i
} else if (isNumber(x.prop) && !x.propEnd && !isProp(v)) {
} else if (isNumber(x.prop) && !x.propEnd && !isIdentifier(v)) {
x.propEnd = i
} else if (isNumber(x.propEnd) && !isNumber(x.value) && v !== ' ' && v !== '\n' && v !== ':') {
x.value = i
Expand Down

0 comments on commit 18acd32

Please sign in to comment.