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() {