From 330ffa92cd58f49172006294f81e6526daa516cb Mon Sep 17 00:00:00 2001 From: Itai Gilo Date: Tue, 20 Jul 2021 15:35:29 +0300 Subject: [PATCH 1/2] Support more directions --- lib/parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/parser.js b/lib/parser.js index cdc8464..a60957a 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -11,7 +11,7 @@ GradientParser.parse = (function() { repeatingLinearGradient: /^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i, radialGradient: /^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i, repeatingRadialGradient: /^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i, - sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|left|right|top|bottom)/i, + sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i, extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/, positionKeywords: /^(left|center|right|top|bottom)/i, pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/, From a3494b3421259dc1d1fada7842617bf5d8a1cd5a Mon Sep 17 00:00:00 2001 From: Itai Gilo Date: Tue, 20 Jul 2021 15:45:38 +0300 Subject: [PATCH 2/2] Add tests --- spec/parser.spec.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/parser.spec.js b/spec/parser.spec.js index 2177f09..68defe9 100644 --- a/spec/parser.spec.js +++ b/spec/parser.spec.js @@ -134,7 +134,11 @@ describe('lib/parser.js', function () { describe('parse all linear directional', function() { [ {type: 'angular', unparsedValue: '-145deg', value: '-145'}, - {type: 'directional', unparsedValue: 'to left top', value: 'left top'} + {type: 'directional', unparsedValue: 'to left top', value: 'left top'}, + {type: 'directional', unparsedValue: 'to top left', value: 'top left'}, + {type: 'directional', unparsedValue: 'to top right', value: 'top right'}, + {type: 'directional', unparsedValue: 'to bottom left', value: 'bottom left'}, + {type: 'directional', unparsedValue: 'to bottom right', value: 'bottom right'} ].forEach(function(orientation) { describe('parse orientation ' + orientation.type, function() { beforeEach(function() {