From 7aab554db3917c0f40dd24f331bf24707cda7180 Mon Sep 17 00:00:00 2001 From: Jacob Parker Date: Thu, 24 Nov 2016 10:08:02 +0000 Subject: [PATCH] Fix shorthands with multiple digits --- src/grammar.ne | 12 ++++++------ src/index.test.js | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/grammar.ne b/src/grammar.ne index 50ee2e3..c69a116 100644 --- a/src/grammar.ne +++ b/src/grammar.ne @@ -131,19 +131,19 @@ border } }) %} margin - -> number (_ number):* {% combineClockwiseShorthand('margin') %} + -> number (__ number):* {% combineClockwiseShorthand('margin') %} padding - -> number (_ number):* {% combineClockwiseShorthand('padding') %} + -> number (__ number):* {% combineClockwiseShorthand('padding') %} borderWidth - -> number (_ number):* {% combineClockwiseShorthand('border', undefined, 'Width') %} + -> number (__ number):* {% combineClockwiseShorthand('border', undefined, 'Width') %} borderColor - -> color (_ color):* {% combineClockwiseShorthand('border', undefined, 'Color') %} + -> color (__ color):* {% combineClockwiseShorthand('border', undefined, 'Color') %} borderRadius - -> number (_ number):* {% + -> number (__ number):* {% combineClockwiseShorthand('border', ['TopLeft', 'TopRight', 'BottomRight', 'BottomLeft'], 'Radius') %} @@ -157,7 +157,7 @@ flexFlow } }) %} flex - -> number (_ number):* {% (d, location, reject) => { + -> number (__ number):* {% (d, location, reject) => { const values = combineHeadTail(d); if (values.length > 3) return reject; const [flexGrow, flexShrink = 1, flexBasis = 0] = values; diff --git a/src/index.test.js b/src/index.test.js index fd83e8f..792d521 100644 --- a/src/index.test.js +++ b/src/index.test.js @@ -148,20 +148,20 @@ it('transforms border shorthand missing color & style', () => runTest([ ], { borderWidth: 2, borderColor: 'black', borderStyle: 'solid' })); it('transforms margin shorthands using 4 values', () => runTest([ - ['margin', '1 2 3 4'], -], { marginTop: 1, marginRight: 2, marginBottom: 3, marginLeft: 4 })); + ['margin', '10 20 30 40'], +], { marginTop: 10, marginRight: 20, marginBottom: 30, marginLeft: 40 })); it('transforms margin shorthands using 3 values', () => runTest([ - ['margin', '1 2 3'], -], { marginTop: 1, marginRight: 2, marginBottom: 3, marginLeft: 2 })); + ['margin', '10 20 30'], +], { marginTop: 10, marginRight: 20, marginBottom: 30, marginLeft: 20 })); it('transforms margin shorthands using 2 values', () => runTest([ - ['margin', '1 2'], -], { marginTop: 1, marginRight: 2, marginBottom: 1, marginLeft: 2 })); + ['margin', '10 20'], +], { marginTop: 10, marginRight: 20, marginBottom: 10, marginLeft: 20 })); it('transforms margin shorthands using 1 value', () => runTest([ - ['margin', '1'], -], { marginTop: 1, marginRight: 1, marginBottom: 1, marginLeft: 1 })); + ['margin', '10'], +], { marginTop: 10, marginRight: 10, marginBottom: 10, marginLeft: 10 })); it('shorthand with 1 value should override previous values', () => runTest([ ['margin-top', '2'],