Skip to content

Commit 483e355

Browse files
committed
Fix #41: NaN value when reducing division with custom property
1 parent 704fe47 commit 483e355

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/__tests__/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ test(
154154
'calc(-90px + var(--mouseX))'
155155
)
156156

157+
test(
158+
'should ignore calc with css variables (6)',
159+
testFixture,
160+
'calc(var(--popupHeight) / 2)',
161+
'calc(var(--popupHeight) / 2)'
162+
)
163+
157164
test(
158165
'should reduce calc with newline characters',
159166
testFixture,

src/lib/reducer.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,12 @@ function reduceDivisionExpression(node, precision) {
223223
}
224224
return node
225225
}
226-
227-
// value / value
228-
node.left.value /= node.right.value
229-
return node.left
226+
// something / value
227+
else if (isValueType(node.left.type)) {
228+
node.left.value /= node.right.value
229+
return node.left
230+
}
231+
return node
230232
}
231233

232234
function reduceMultiplicationExpression(node) {

0 commit comments

Comments
 (0)