From ce4521b1b3d45b02f8cf4edc0b18ab78f6750dd5 Mon Sep 17 00:00:00 2001 From: Rafael Caricio Date: Thu, 11 Sep 2014 17:46:08 +0200 Subject: [PATCH] Match browser prefixes --- build/node.js | 8 ++++---- build/web.js | 8 ++++---- lib/parser.js | 8 ++++---- spec/parser.spec.js | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/build/node.js b/build/node.js index b54734a..c59fe3a 100644 --- a/build/node.js +++ b/build/node.js @@ -7,10 +7,10 @@ var GradientParser = {}; GradientParser.parse = (function() { var tokens = { - linearGradient: /^linear\-gradient/i, - repeatingLinearGradient: /^repeating\-linear\-gradient/i, - radialGradient: /^radial\-gradient/i, - repeatingRadialGradient: /^repeating\-radial\-gradient/i, + linearGradient: /^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i, + 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, extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/, positionKeywords: /^(left|center|right|top|bottom)/i, diff --git a/build/web.js b/build/web.js index 64417f1..bba8a79 100644 --- a/build/web.js +++ b/build/web.js @@ -7,10 +7,10 @@ var GradientParser = {}; GradientParser.parse = (function() { var tokens = { - linearGradient: /^linear\-gradient/i, - repeatingLinearGradient: /^repeating\-linear\-gradient/i, - radialGradient: /^radial\-gradient/i, - repeatingRadialGradient: /^repeating\-radial\-gradient/i, + linearGradient: /^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i, + 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, extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/, positionKeywords: /^(left|center|right|top|bottom)/i, diff --git a/lib/parser.js b/lib/parser.js index 64417f1..bba8a79 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -7,10 +7,10 @@ var GradientParser = {}; GradientParser.parse = (function() { var tokens = { - linearGradient: /^linear\-gradient/i, - repeatingLinearGradient: /^repeating\-linear\-gradient/i, - radialGradient: /^radial\-gradient/i, - repeatingRadialGradient: /^repeating\-radial\-gradient/i, + linearGradient: /^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i, + 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, extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/, positionKeywords: /^(left|center|right|top|bottom)/i, diff --git a/spec/parser.spec.js b/spec/parser.spec.js index c785361..6856adf 100644 --- a/spec/parser.spec.js +++ b/spec/parser.spec.js @@ -15,13 +15,13 @@ describe('gradient-parser.js', function () { describe('error cases', function() { it('one more comma in definitions', function() { expect(function() { - gradients.parse('linear-gradient(red, blue),'); + gradients.parse('-webkit-linear-gradient(red, blue),'); }).to.throwException(/One extra comma/); }); it('one more comma in colors', function() { expect(function() { - gradients.parse('linear-gradient(red, blue,)'); + gradients.parse('-o-linear-gradient(red, blue,)'); }).to.throwException(/Expected color definition/); });