Skip to content

Commit 0bb7f1f

Browse files
committed
#39 Fix throwing error for attribute selectors without a value
1 parent b20182e commit 0bb7f1f

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/__tests__/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,10 @@ testThrows(
206206
'foo{bar:calc(500px/2px)}',
207207
/Cannot divide by "px", number expected/
208208
);
209+
210+
test(
211+
'should return the same and not thrown an exception for attribute selectors without a value',
212+
'button[disabled]{}',
213+
'button[disabled]{}',
214+
{ selectors: true }
215+
);

src/lib/transform.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import reduceCssCalc from 'reduce-css-calc';
44
const MATCH_CALC = /((?:\-[a-z]+\-)?calc)/;
55

66
function transformValue(value, options, result, item) {
7+
if (!value) {
8+
return value;
9+
}
10+
711
const reduced = reduceCssCalc(value, options.precision)
812
// if the warnWhenCannotResolve option is on, inform the user that the calc
913
// expression could not be resolved to a single value

0 commit comments

Comments
 (0)