From 6c57770890377c13dfcdb70662d1d4909e0806f9 Mon Sep 17 00:00:00 2001 From: Rafael Caricio Date: Thu, 11 Sep 2014 18:02:58 +0200 Subject: [PATCH] Match negatives and float values --- build/node.js | 8 ++++---- build/web.js | 8 ++++---- lib/parser.js | 8 ++++---- spec/parser.spec.js | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build/node.js b/build/node.js index c59fe3a..fcd0bcb 100644 --- a/build/node.js +++ b/build/node.js @@ -14,10 +14,10 @@ GradientParser.parse = (function() { sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|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]+)px/, - percentageValue: /^([0-9]+)\%/, - emValue: /^([0-9]+)em/, - angleValue: /^([0-9]+)deg/, + pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/, + percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/, + emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/, + angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/, startCall: /^\(/, endCall: /^\)/, comma: /^,/, diff --git a/build/web.js b/build/web.js index bba8a79..de8fd61 100644 --- a/build/web.js +++ b/build/web.js @@ -14,10 +14,10 @@ GradientParser.parse = (function() { sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|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]+)px/, - percentageValue: /^([0-9]+)\%/, - emValue: /^([0-9]+)em/, - angleValue: /^([0-9]+)deg/, + pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/, + percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/, + emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/, + angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/, startCall: /^\(/, endCall: /^\)/, comma: /^,/, diff --git a/lib/parser.js b/lib/parser.js index bba8a79..de8fd61 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -14,10 +14,10 @@ GradientParser.parse = (function() { sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|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]+)px/, - percentageValue: /^([0-9]+)\%/, - emValue: /^([0-9]+)em/, - angleValue: /^([0-9]+)deg/, + pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/, + percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/, + emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/, + angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/, startCall: /^\(/, endCall: /^\)/, comma: /^,/, diff --git a/spec/parser.spec.js b/spec/parser.spec.js index 6856adf..e1281c6 100644 --- a/spec/parser.spec.js +++ b/spec/parser.spec.js @@ -197,7 +197,7 @@ describe('gradient-parser.js', function () { 'ellipse cover', 'circle cover', 'center bottom, ellipse cover', - 'circle at 119px 58px' + 'circle at 87.23px -58.3px' ].forEach(function(declaration) { it('should parse ' + declaration + ' declaration', function() {