Skip to content

Commit 7aab554

Browse files
committed
Fix shorthands with multiple digits
1 parent e5cf247 commit 7aab554

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/grammar.ne

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,19 @@ border
131131
} }) %}
132132

133133
margin
134-
-> number (_ number):* {% combineClockwiseShorthand('margin') %}
134+
-> number (__ number):* {% combineClockwiseShorthand('margin') %}
135135

136136
padding
137-
-> number (_ number):* {% combineClockwiseShorthand('padding') %}
137+
-> number (__ number):* {% combineClockwiseShorthand('padding') %}
138138

139139
borderWidth
140-
-> number (_ number):* {% combineClockwiseShorthand('border', undefined, 'Width') %}
140+
-> number (__ number):* {% combineClockwiseShorthand('border', undefined, 'Width') %}
141141

142142
borderColor
143-
-> color (_ color):* {% combineClockwiseShorthand('border', undefined, 'Color') %}
143+
-> color (__ color):* {% combineClockwiseShorthand('border', undefined, 'Color') %}
144144

145145
borderRadius
146-
-> number (_ number):* {%
146+
-> number (__ number):* {%
147147
combineClockwiseShorthand('border', ['TopLeft', 'TopRight', 'BottomRight', 'BottomLeft'], 'Radius')
148148
%}
149149

@@ -157,7 +157,7 @@ flexFlow
157157
} }) %}
158158

159159
flex
160-
-> number (_ number):* {% (d, location, reject) => {
160+
-> number (__ number):* {% (d, location, reject) => {
161161
const values = combineHeadTail(d);
162162
if (values.length > 3) return reject;
163163
const [flexGrow, flexShrink = 1, flexBasis = 0] = values;

src/index.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,20 @@ it('transforms border shorthand missing color & style', () => runTest([
148148
], { borderWidth: 2, borderColor: 'black', borderStyle: 'solid' }));
149149

150150
it('transforms margin shorthands using 4 values', () => runTest([
151-
['margin', '1 2 3 4'],
152-
], { marginTop: 1, marginRight: 2, marginBottom: 3, marginLeft: 4 }));
151+
['margin', '10 20 30 40'],
152+
], { marginTop: 10, marginRight: 20, marginBottom: 30, marginLeft: 40 }));
153153

154154
it('transforms margin shorthands using 3 values', () => runTest([
155-
['margin', '1 2 3'],
156-
], { marginTop: 1, marginRight: 2, marginBottom: 3, marginLeft: 2 }));
155+
['margin', '10 20 30'],
156+
], { marginTop: 10, marginRight: 20, marginBottom: 30, marginLeft: 20 }));
157157

158158
it('transforms margin shorthands using 2 values', () => runTest([
159-
['margin', '1 2'],
160-
], { marginTop: 1, marginRight: 2, marginBottom: 1, marginLeft: 2 }));
159+
['margin', '10 20'],
160+
], { marginTop: 10, marginRight: 20, marginBottom: 10, marginLeft: 20 }));
161161

162162
it('transforms margin shorthands using 1 value', () => runTest([
163-
['margin', '1'],
164-
], { marginTop: 1, marginRight: 1, marginBottom: 1, marginLeft: 1 }));
163+
['margin', '10'],
164+
], { marginTop: 10, marginRight: 10, marginBottom: 10, marginLeft: 10 }));
165165

166166
it('shorthand with 1 value should override previous values', () => runTest([
167167
['margin-top', '2'],

0 commit comments

Comments
 (0)