diff --git a/lib/create.js b/lib/create.js index 1340ff4..06db676 100644 --- a/lib/create.js +++ b/lib/create.js @@ -196,7 +196,7 @@ export default function bss({ if (selector.indexOf('animation') === 0) props.out.push(['animation', selector.slice(10) + ' ' + x]) parseAddProps(ani || at || supports || rules, i, x, props, level) - props.prop = props.value = props.propEnd = null + props.prop = props.value = props.propEnd = props.strict = null selector.indexOf('@supports') === 0 ? supports = Object.assign([], { selector }) : selector[0] === '@' @@ -247,7 +247,7 @@ export default function bss({ propEnd: null, value: null, out: [], - lean: true, + strict: null, comma: 0, end: 0, quote: false @@ -255,8 +255,8 @@ export default function bss({ } function propsParseLoop(s, i, v, x) { - if (!x.value && x.prop !== null && x.lean && v === ':') - x.lean = false + if (!x.value && x.prop !== null && !x.strict && v === ':') + x.strict = true if (!x.value && x.prop !== null && x.out.length && v === ',') { x.value = x.comma x.prop = x.out[x.out.length - 1][0] @@ -279,7 +279,7 @@ export default function bss({ && (i === s.length - 1 || s[i + 1] === ';' || s[i + 1] === '}' - || (x.lean + || (!x.strict && s[i - 1] !== ',' && v === '\n' ) @@ -292,13 +292,12 @@ export default function bss({ ) x.end = i + (s[i + 1] === ';' ? 2 : 1) x.comma = x.value - x.value = x.prop = x.propEnd = null - x.lean = true + x.value = x.prop = x.propEnd = x.strict = null } } function propParse(key, value, x) { - if (!x.lean) + if (x.strict) return [key, value] key = props.reduce((acc, fn) => fn(acc), key.trim()) diff --git a/tests/index.js b/tests/index.js index 471add6..0c09759 100644 --- a/tests/index.js +++ b/tests/index.js @@ -139,6 +139,31 @@ t('Fails gracefully on bad prop syntax', () => { ] }) +t('Mixed strict and lean works', () => { + b` + bc blue + bc:blue; + `.toString() + + return [ + cn() + cn() + '{background-color:blue;bc:blue;}', + b.rules.pop() + ] +}) + +t('Mixed nesting and lean works', () => { + b` + input:checked + label::after { + w 18 + } + `.toString() + + return [ + b.rules.pop(), + cn() + ' input:checked + label::after{width:18px;}' + ] +}) + t('Support multiline props', () => { b` transform: translateY(20px)