Skip to content

Commit b14b66c

Browse files
committed
Allow css-style .5 numbers
1 parent b2a3d04 commit b14b66c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/grammar.ne

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

52+
int
53+
-> "0" | [1-9] [0-9]:*
54+
55+
decimal
56+
-> "." [0-9]:+
57+
5258
number
53-
-> "-":? ([0-9]:? "." [0-9]:+ | [1-9] [0-9]:* ("." [0-9]:+):? | "0") {% d => Number(text(d)) %}
59+
-> "-":? (int decimal | int | decimal) {% d => Number(text(d)) %}
5460

5561
angle -> number ("deg" | "rad") {% text %}
5662

src/index.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ it('allows decimal values', () => {
2222
expect(parseProp('number', '-1.5')).toBe(-1.5);
2323
expect(parseProp('number', '-10.5')).toBe(-10.5);
2424
expect(parseProp('number', '-100.5')).toBe(-100.5);
25+
expect(parseProp('number', '.5')).toBe(0.5);
26+
expect(parseProp('number', '-.5')).toBe(-0.5);
2527
});
2628

2729
it('allows decimal values in transformed values', () => runTest([

0 commit comments

Comments
 (0)