Skip to content

Fix numbers with decimals #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 21, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix negative values
  • Loading branch information
jacobp100 committed Nov 21, 2016
commit 79589b27e9d9d75f04e9005fa42b1b8f740fa5df
4 changes: 1 addition & 3 deletions src/grammar.ne
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@
%}

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

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

Expand Down
9 changes: 9 additions & 0 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ it('allows decimal values in transformed values', () => runTest([
borderBottomLeftRadius: 1.5,
}));

it('allows negative values in transformed values', () => runTest([
['border-radius', '-1.5'],
], {
borderTopLeftRadius: -1.5,
borderTopRightRadius: -1.5,
borderBottomRightRadius: -1.5,
borderBottomLeftRadius: -1.5,
}));

it('transforms strings', () => runTest([
['color', 'red'],
], { color: 'red' }));
Expand Down