Skip to content

Commit 5dce7fe

Browse files
committed
Fix numbers with decimals
1 parent 390e15d commit 5dce7fe

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/grammar.ne

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@
4949
};
5050
%}
5151

52-
number -> ([0-9]:+) {% d => Number(text(d)) %}
52+
number
53+
-> ([0-9]:? "." [0-9]:+) {% d => Number(text(d)) %}
54+
| ([1-9] [0-9]:*) {% d => Number(text(d)) %}
55+
| "0" {% d => Number(text(d)) %}
5356

5457
angle -> number ("deg" | "rad") {% text %}
5558

src/index.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ it('allows decimal values', () => runTest([
1717
['top', '1.5'],
1818
], { top: 1.5 }));
1919

20+
it('allows decimal values in transformed values', () => runTest([
21+
['border-radius', '1.5'],
22+
], {
23+
borderTopLeftRadius: 1.5,
24+
borderTopRightRadius: 1.5,
25+
borderBottomRightRadius: 1.5,
26+
borderBottomLeftRadius: 1.5,
27+
}));
28+
2029
it('transforms strings', () => runTest([
2130
['color', 'red'],
2231
], { color: 'red' }));

0 commit comments

Comments
 (0)