From 18ea4160a655b3e5fa957446279ecfb039cb9e03 Mon Sep 17 00:00:00 2001 From: Onno van der Zee Date: Mon, 7 Sep 2015 00:45:11 +0200 Subject: [PATCH 01/11] new paint validation type --- src/css/ValidationTypes.js | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/css/ValidationTypes.js b/src/css/ValidationTypes.js index 538cd710..5f87b0fa 100644 --- a/src/css/ValidationTypes.js +++ b/src/css/ValidationTypes.js @@ -132,6 +132,24 @@ var ValidationTypes = { return part.type == "color" || part == "transparent" || part == "currentColor"; }, + "": function(part){ + /* ex.: + + https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/local + icc-color(acmecmyk, 0.11, 0.48, 0.83, 0.00) + cielab(62.253188, 23.950124, 48.410653) + cielch(62.253188, 54.011108, 63.677091) + icc-color(FooColors, Sandy23C) + + http://www.w3.org/TR/2009/WD-SVGColor12-20091001/#iccnamedcolor + ~"icc-color(" name (comma-wsp number)+ ")" + ~"icc-named-color(" name comma-wsp namedColor ")" + ~"cielab(" lightness comma-wsp a-value comma-wsp b-value ")" + ~"cielchab(" lightness comma-wsp chroma comma-wsp hue ")" + + */ + }, + "": function(part){ return part.type == "number" || this[""](part); }, @@ -332,6 +350,34 @@ var ValidationTypes = { }, + "": function(expression) { + /* + none | currentColor | [] | + [ none | currentColor | [] ] | + inherit + => + | || | inherit + */ + }, + + "": function(expression) { + // none | currentColor | [] + var part, result; + + if (expression.hasNext()) { + part = expression.next(); + result = ValidationTypes.isLiteral(part, "none") || ValidationTypes.simple[""](part); + if (expression.hasNext()) { + part = expression.next(); + result = result && ValidationTypes.simple[""](part); + result = result && !expression.hasNext(); + } + } + + return result; + + }, + "": function(expression) { //inset? && [ {2,4} && ? ] var result = false, From f31f8043ff63e7943ed6a6ea4c0c018b655980d2 Mon Sep 17 00:00:00 2001 From: Onno van der Zee Date: Mon, 7 Sep 2015 16:02:59 +0200 Subject: [PATCH 02/11] icccolor validation --- src/css/ValidationTypes.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/css/ValidationTypes.js b/src/css/ValidationTypes.js index 5f87b0fa..763c4b2b 100644 --- a/src/css/ValidationTypes.js +++ b/src/css/ValidationTypes.js @@ -134,20 +134,24 @@ var ValidationTypes = { "": function(part){ /* ex.: - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/local - icc-color(acmecmyk, 0.11, 0.48, 0.83, 0.00) - cielab(62.253188, 23.950124, 48.410653) - cielch(62.253188, 54.011108, 63.677091) - icc-color(FooColors, Sandy23C) - + icc-color(acmecmyk, 0.11, 0.48, 0.83, 0.00) + cielab(62.253188, 23.950124, 48.410653) + cielch(62.253188, 54.011108, 63.677091) + icc-color(FooColors, Sandy23C) http://www.w3.org/TR/2009/WD-SVGColor12-20091001/#iccnamedcolor - ~"icc-color(" name (comma-wsp number)+ ")" - ~"icc-named-color(" name comma-wsp namedColor ")" - ~"cielab(" lightness comma-wsp a-value comma-wsp b-value ")" - ~"cielchab(" lightness comma-wsp chroma comma-wsp hue ")" - + ~"icc-color(" name (comma-wsp number)+ ")" + ~"icc-named-color(" name comma-wsp namedColor ")" + ~"cielab(" lightness comma-wsp a-value comma-wsp b-value ")" + ~"cielchab(" lightness comma-wsp chroma comma-wsp hue ")" */ + return part.type == 'function' && ( + part.name == 'cielab' || + part.name == 'cielch' || + part.name == 'cielchab' || + part.name == 'icc-color' || + part.name == 'icc-named-color' + ); }, "": function(part){ From 050d07988a790f78e981853e5fc0fd109f475a50 Mon Sep 17 00:00:00 2001 From: Onno van der Zee Date: Mon, 7 Sep 2015 21:36:02 +0200 Subject: [PATCH 03/11] paint and opacity, no paint-uni, no tabs --- src/css/ValidationTypes.js | 45 ++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/css/ValidationTypes.js b/src/css/ValidationTypes.js index 763c4b2b..9c877b79 100644 --- a/src/css/ValidationTypes.js +++ b/src/css/ValidationTypes.js @@ -145,7 +145,7 @@ var ValidationTypes = { ~"cielab(" lightness comma-wsp a-value comma-wsp b-value ")" ~"cielchab(" lightness comma-wsp chroma comma-wsp hue ")" */ - return part.type == 'function' && ( + return part.type == 'function' && ( part.name == 'cielab' || part.name == 'cielch' || part.name == 'cielchab' || @@ -158,6 +158,10 @@ var ValidationTypes = { return part.type == "number" || this[""](part); }, + "": function(part){ + return this[""](part) && part.value >= 0 && part.value <= 1; + }, + "": function(part){ return part.type == "integer"; }, @@ -233,7 +237,7 @@ var ValidationTypes = { "": function(part){ return ValidationTypes.isLiteral(part, "nowrap | wrap | wrap-reverse"); }, - + "": function(part){ return (part.type == "function" && /^[A-Z0-9]{4}$/i.test(part)); } @@ -359,26 +363,25 @@ var ValidationTypes = { none | currentColor | [] | [ none | currentColor | [] ] | inherit - => - | || | inherit */ - }, - - "": function(expression) { - // none | currentColor | [] - var part, result; - - if (expression.hasNext()) { - part = expression.next(); - result = ValidationTypes.isLiteral(part, "none") || ValidationTypes.simple[""](part); - if (expression.hasNext()) { - part = expression.next(); - result = result && ValidationTypes.simple[""](part); - result = result && !expression.hasNext(); - } - } - - return result; + var part = expression.next(), result = false; + + if (ValidationTypes.simple[""](part)) { + result = true; + part = expression.next(); + } + if (part && ValidationTypes.simple[""](part)) { + var color = part.value; + result = true; + part = expression.next(); + if (part) { + result = (color != 'currentColor') && ValidationTypes.simple[""](part); + } + } else if (part) { + result = ValidationTypes.isLiteral(part, "none | currentColor | inherit"); + } + + return result && !expression.hasNext(); }, From 69c01336b263181fdd664469c091d8c5271a6bd2 Mon Sep 17 00:00:00 2001 From: Onno van der Zee Date: Mon, 7 Sep 2015 22:01:05 +0200 Subject: [PATCH 04/11] strokeproperties --- src/css/ValidationTypes.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/css/ValidationTypes.js b/src/css/ValidationTypes.js index 9c877b79..46ab2a2c 100644 --- a/src/css/ValidationTypes.js +++ b/src/css/ValidationTypes.js @@ -158,6 +158,10 @@ var ValidationTypes = { return part.type == "number" || this[""](part); }, + "": function(part){ + return this[""](part) && part.value >= 1; + }, + "": function(part){ return this[""](part) && part.value >= 0 && part.value <= 1; }, @@ -439,6 +443,25 @@ var ValidationTypes = { return result; }, + "": function(expression){ + var arrayResult = true, part, partResult; + + while (expression.hasNext()) { + part = expression.next(); + partResult = + part.value >= 0 && ( + ValidationTypes.simple[""](part) || + ValidationTypes.simple[""](part) || + ValidationTypes.simple[""](part) + ); + partResult = partResult || part.value == ','; + arrayResult = arrayResult && partResult; + } + + return arrayResult; + + }, + "": function(expression) { // http://www.w3.org/TR/2014/WD-css-flexbox-1-20140325/#flex-property // none | [ ? || ] From 2507fdaee2094c6748731617eed0c16d85444682 Mon Sep 17 00:00:00 2001 From: Onno van der Zee Date: Mon, 7 Sep 2015 22:02:47 +0200 Subject: [PATCH 05/11] fill, stroke, opacity properties --- src/css/Properties.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/css/Properties.js b/src/css/Properties.js index 4764a1b7..de07b17b 100644 --- a/src/css/Properties.js +++ b/src/css/Properties.js @@ -284,6 +284,9 @@ var Properties = { "empty-cells" : "show | hide | inherit", //F + "fill" : "", + "fill-opacity" : " | inherit", + "fill-rule" : "nonzero | evenodd | inherit", "filter" : 1, "fit" : "fill | hidden | meet | slice", "fit-position" : 1, @@ -417,7 +420,7 @@ var Properties = { //O "object-fit" : "fill | contain | cover | none | scale-down", "object-position" : "", - "opacity" : " | inherit", + "opacity" : " | inherit", "order" : "", "-webkit-order" : "", "orphans" : " | inherit", @@ -485,6 +488,14 @@ var Properties = { "src" : 1, "stress" : 1, "string-set" : 1, + "stroke" : "", + "stroke-dasharray" : "none | | inherit", + "stroke-dashoffset" : " | | inherit", + "stroke-linecap" : "butt | round | square | inherit", + "stroke-linejoin" : "miter | round | bevel | inherit", + "stroke-miterlimit" : " | inherit", + "stroke-opacity" : " | inherit", + "stroke-width" : " | | inherit", "table-layout" : "auto | fixed | inherit", "tab-size" : " | ", From 164c06139bc32ffcb84f1e16dd14144f5d8b183a Mon Sep 17 00:00:00 2001 From: Onno van der Zee Date: Mon, 7 Sep 2015 22:52:08 +0200 Subject: [PATCH 06/11] validation tests --- tests/css/Validation.js | 115 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 1 deletion(-) diff --git a/tests/css/Validation.js b/tests/css/Validation.js index adcae30d..809e51c3 100644 --- a/tests/css/Validation.js +++ b/tests/css/Validation.js @@ -673,6 +673,46 @@ } })); + // test + suite.add(new ValidationTestCase({ + property: "fill", + + valid: [ + "url('myGradient')", + "url('myGradient') inherit", + "url('myGradient') darkred", + "url('myGradient') darkred icc-color(myCmykDarkRed)", + "currentColor", + "darkred icc-color(myCmykDarkRed)", + "none", + "inherit" + ], + + invalid: { + "url('myGradient') icc-color(myCmykDarkRed)" : "Expected () but found 'url('myGradient') icc-color(myCmykDarkRed)'.", + "currentColor icc-color(myCmykDarkRed)" : "Expected () but found 'currentColor icc-color(myCmykDarkRed)'.", + "icc-color(myCmykDarkRed) darkred" : "Expected () but found 'icc-color(myCmykDarkRed) darkred'.", + "icc-color(myCmykDarkRed)" : "Expected () but found 'icc-color(myCmykDarkRed)'.", + "icc-color(myCmykDarkRed) inherit" : "Expected () but found 'icc-color(myCmykDarkRed) inherit'.", + "inherit icc-color(myCmykDarkRed)" : "Expected () but found 'inherit icc-color(myCmykDarkRed)'.", + "none inherit" : "Expected () but found 'none inherit'." + } + })); + + suite.add(new ValidationTestCase({ + property: "fill-rule", + + valid: [ + "nonzero", + "evenodd", + "inherit" + ], + + invalid: { + "foo" : "Expected (nonzero | evenodd | inherit) but found 'foo'." + } + })); + ["flex", "-ms-flex", "-webkit-flex"].forEach(function(prop_name) { suite.add(new ValidationTestCase({ property: prop_name, @@ -894,11 +934,15 @@ property: "opacity", valid: [ + "0", + "0.5", "1" ], invalid: { - "foo" : "Expected ( | inherit) but found 'foo'." + "-0.75" : "Expected ( | inherit) but found '-0.75'.", + "12" : "Expected ( | inherit) but found '12'.", + "foo" : "Expected ( | inherit) but found 'foo'." } })); @@ -924,6 +968,75 @@ } })); + suite.add(new ValidationTestCase({ + property: "stroke-dasharray", + + valid: [ + "0", + "4", + "20px", + "20px 40px 30px", + "20px, 40px, 30px", + "none", + "inherit" + ], + + invalid: { + "-20px" : "Expected (none | | inherit) but found '-20px'.", + "auto" : "Expected (none | | inherit) but found 'auto'." + } + })); + + suite.add(new ValidationTestCase({ + property: "stroke-linecap", + + valid: [ + "butt", + "round", + "square", + "inherit" + ], + + invalid: { + "auto" : "Expected (butt | round | square | inherit) but found 'auto'." + "none" : "Expected (butt | round | square | inherit) but found 'none'." + } + })); + + suite.add(new ValidationTestCase({ + property: "stroke-linejoin", + + valid: [ + "miter", + "round", + "bevel", + "inherit" + ], + + invalid: { + "auto" : "Expected (miter | round | bevel | inherit) but found 'auto'." + "none" : "Expected (miter | round | bevel | inherit) but found 'none'." + } + })); + + suite.add(new ValidationTestCase({ + property: "stroke-miterlimit", + + valid: [ + "1", + "1.4", + "20", + "10", + "inherit" + ], + + invalid: { + "-10" : "Expected () but found '-10'.", + "0.5" : "Expected () but found '0.5'.", + "foo" : "Expected () but found 'foo'." + } + })); + suite.add(new ValidationTestCase({ property: "-ms-touch-action", From bb670223e9b794fce3c41bef82b807e773374826 Mon Sep 17 00:00:00 2001 From: Onno van der Zee Date: Fri, 11 Sep 2015 14:27:54 +0200 Subject: [PATCH 07/11] fix tests --- tests/css/Validation.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/css/Validation.js b/tests/css/Validation.js index 809e51c3..b78b8253 100644 --- a/tests/css/Validation.js +++ b/tests/css/Validation.js @@ -998,7 +998,7 @@ ], invalid: { - "auto" : "Expected (butt | round | square | inherit) but found 'auto'." + "auto" : "Expected (butt | round | square | inherit) but found 'auto'.", "none" : "Expected (butt | round | square | inherit) but found 'none'." } })); @@ -1014,7 +1014,7 @@ ], invalid: { - "auto" : "Expected (miter | round | bevel | inherit) but found 'auto'." + "auto" : "Expected (miter | round | bevel | inherit) but found 'auto'.", "none" : "Expected (miter | round | bevel | inherit) but found 'none'." } })); @@ -1031,9 +1031,9 @@ ], invalid: { - "-10" : "Expected () but found '-10'.", - "0.5" : "Expected () but found '0.5'.", - "foo" : "Expected () but found 'foo'." + "-10" : "Expected ( | inherit) but found '-10'.", + "0.5" : "Expected ( | inherit) but found '0.5'.", + "foo" : "Expected ( | inherit) but found 'foo'." } })); From d6c6281afd13b0a2ec379317f4592cd4f07bf2f7 Mon Sep 17 00:00:00 2001 From: Onno van der Zee Date: Fri, 11 Sep 2015 14:29:21 +0200 Subject: [PATCH 08/11] fix icc-colortests --- tests/css/Validation.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/css/Validation.js b/tests/css/Validation.js index b78b8253..f618090c 100644 --- a/tests/css/Validation.js +++ b/tests/css/Validation.js @@ -691,11 +691,11 @@ invalid: { "url('myGradient') icc-color(myCmykDarkRed)" : "Expected () but found 'url('myGradient') icc-color(myCmykDarkRed)'.", "currentColor icc-color(myCmykDarkRed)" : "Expected () but found 'currentColor icc-color(myCmykDarkRed)'.", - "icc-color(myCmykDarkRed) darkred" : "Expected () but found 'icc-color(myCmykDarkRed) darkred'.", + "icc-color(myCmykDarkRed) darkred" : "Expected end of value but found 'darkred'.", "icc-color(myCmykDarkRed)" : "Expected () but found 'icc-color(myCmykDarkRed)'.", - "icc-color(myCmykDarkRed) inherit" : "Expected () but found 'icc-color(myCmykDarkRed) inherit'.", - "inherit icc-color(myCmykDarkRed)" : "Expected () but found 'inherit icc-color(myCmykDarkRed)'.", - "none inherit" : "Expected () but found 'none inherit'." + "icc-color(myCmykDarkRed) inherit" : "Expected end of value but found 'inherit'.", + "inherit icc-color(myCmykDarkRed)" : "Expected end of value but found 'icc-color(myCmykDarkRed)'.", + "none inherit" : "Expected end of value but found 'inherit'." } })); From 444c755c2bd9310f46ba6cec2232b0643ad39b45 Mon Sep 17 00:00:00 2001 From: Onno van der Zee Date: Fri, 11 Sep 2015 14:42:48 +0200 Subject: [PATCH 09/11] leave a dasharray part to check inherit --- src/css/ValidationTypes.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/css/ValidationTypes.js b/src/css/ValidationTypes.js index 46ab2a2c..1d92df85 100644 --- a/src/css/ValidationTypes.js +++ b/src/css/ValidationTypes.js @@ -458,6 +458,9 @@ var ValidationTypes = { arrayResult = arrayResult && partResult; } + if (!arrayResult) { + expression.previous(); + } return arrayResult; }, From 9c6d47b9705f21246675f74dc1ece53223b1877e Mon Sep 17 00:00:00 2001 From: Dave Lockhart Date: Wed, 6 Jan 2016 11:50:17 -0500 Subject: [PATCH 10/11] fixes #170: allowing a value of "radio" for the appearance property --- src/css/Properties.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/css/Properties.js b/src/css/Properties.js index 4764a1b7..59e6f7b7 100644 --- a/src/css/Properties.js +++ b/src/css/Properties.js @@ -50,7 +50,7 @@ var Properties = { "-o-animation-name" : { multi: "none | ", comma: true }, "-o-animation-play-state" : { multi: "running | paused", comma: true }, - "appearance" : "icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal | none | inherit", + "appearance" : "icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal | none | inherit", "azimuth" : function (expression) { var simple = " | leftwards | rightwards | inherit", direction = "left-side | far-left | left | center-left | center | center-right | right | far-right | right-side", From a1b47ef3b2c248aea0aaa0f3afd973befc664a47 Mon Sep 17 00:00:00 2001 From: Onno van der Zee Date: Mon, 7 Sep 2015 00:45:11 +0200 Subject: [PATCH 11/11] fill, stroke, opacity property --- src/css/Properties.js | 13 ++++- src/css/ValidationTypes.js | 81 +++++++++++++++++++++++++- tests/css/Validation.js | 115 ++++++++++++++++++++++++++++++++++++- 3 files changed, 206 insertions(+), 3 deletions(-) diff --git a/src/css/Properties.js b/src/css/Properties.js index afb74168..62376ae0 100644 --- a/src/css/Properties.js +++ b/src/css/Properties.js @@ -284,6 +284,9 @@ var Properties = { "empty-cells" : "show | hide | inherit", //F + "fill" : "", + "fill-opacity" : " | inherit", + "fill-rule" : "nonzero | evenodd | inherit", "filter" : 1, "fit" : "fill | hidden | meet | slice", "fit-position" : 1, @@ -417,7 +420,7 @@ var Properties = { //O "object-fit" : "fill | contain | cover | none | scale-down", "object-position" : "", - "opacity" : " | inherit", + "opacity" : " | inherit", "order" : "", "-webkit-order" : "", "orphans" : " | inherit", @@ -485,6 +488,14 @@ var Properties = { "src" : 1, "stress" : 1, "string-set" : 1, + "stroke" : "", + "stroke-dasharray" : "none | | inherit", + "stroke-dashoffset" : " | | inherit", + "stroke-linecap" : "butt | round | square | inherit", + "stroke-linejoin" : "miter | round | bevel | inherit", + "stroke-miterlimit" : " | inherit", + "stroke-opacity" : " | inherit", + "stroke-width" : " | | inherit", "table-layout" : "auto | fixed | inherit", "tab-size" : " | ", diff --git a/src/css/ValidationTypes.js b/src/css/ValidationTypes.js index 538cd710..1d92df85 100644 --- a/src/css/ValidationTypes.js +++ b/src/css/ValidationTypes.js @@ -132,10 +132,40 @@ var ValidationTypes = { return part.type == "color" || part == "transparent" || part == "currentColor"; }, + "": function(part){ + /* ex.: + https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/local + icc-color(acmecmyk, 0.11, 0.48, 0.83, 0.00) + cielab(62.253188, 23.950124, 48.410653) + cielch(62.253188, 54.011108, 63.677091) + icc-color(FooColors, Sandy23C) + http://www.w3.org/TR/2009/WD-SVGColor12-20091001/#iccnamedcolor + ~"icc-color(" name (comma-wsp number)+ ")" + ~"icc-named-color(" name comma-wsp namedColor ")" + ~"cielab(" lightness comma-wsp a-value comma-wsp b-value ")" + ~"cielchab(" lightness comma-wsp chroma comma-wsp hue ")" + */ + return part.type == 'function' && ( + part.name == 'cielab' || + part.name == 'cielch' || + part.name == 'cielchab' || + part.name == 'icc-color' || + part.name == 'icc-named-color' + ); + }, + "": function(part){ return part.type == "number" || this[""](part); }, + "": function(part){ + return this[""](part) && part.value >= 1; + }, + + "": function(part){ + return this[""](part) && part.value >= 0 && part.value <= 1; + }, + "": function(part){ return part.type == "integer"; }, @@ -211,7 +241,7 @@ var ValidationTypes = { "": function(part){ return ValidationTypes.isLiteral(part, "nowrap | wrap | wrap-reverse"); }, - + "": function(part){ return (part.type == "function" && /^[A-Z0-9]{4}$/i.test(part)); } @@ -332,6 +362,33 @@ var ValidationTypes = { }, + "": function(expression) { + /* + none | currentColor | [] | + [ none | currentColor | [] ] | + inherit + */ + var part = expression.next(), result = false; + + if (ValidationTypes.simple[""](part)) { + result = true; + part = expression.next(); + } + if (part && ValidationTypes.simple[""](part)) { + var color = part.value; + result = true; + part = expression.next(); + if (part) { + result = (color != 'currentColor') && ValidationTypes.simple[""](part); + } + } else if (part) { + result = ValidationTypes.isLiteral(part, "none | currentColor | inherit"); + } + + return result && !expression.hasNext(); + + }, + "": function(expression) { //inset? && [ {2,4} && ? ] var result = false, @@ -386,6 +443,28 @@ var ValidationTypes = { return result; }, + "": function(expression){ + var arrayResult = true, part, partResult; + + while (expression.hasNext()) { + part = expression.next(); + partResult = + part.value >= 0 && ( + ValidationTypes.simple[""](part) || + ValidationTypes.simple[""](part) || + ValidationTypes.simple[""](part) + ); + partResult = partResult || part.value == ','; + arrayResult = arrayResult && partResult; + } + + if (!arrayResult) { + expression.previous(); + } + return arrayResult; + + }, + "": function(expression) { // http://www.w3.org/TR/2014/WD-css-flexbox-1-20140325/#flex-property // none | [ ? || ] diff --git a/tests/css/Validation.js b/tests/css/Validation.js index 53691856..9e06e185 100644 --- a/tests/css/Validation.js +++ b/tests/css/Validation.js @@ -673,6 +673,46 @@ } })); + // test + suite.add(new ValidationTestCase({ + property: "fill", + + valid: [ + "url('myGradient')", + "url('myGradient') inherit", + "url('myGradient') darkred", + "url('myGradient') darkred icc-color(myCmykDarkRed)", + "currentColor", + "darkred icc-color(myCmykDarkRed)", + "none", + "inherit" + ], + + invalid: { + "url('myGradient') icc-color(myCmykDarkRed)" : "Expected () but found 'url('myGradient') icc-color(myCmykDarkRed)'.", + "currentColor icc-color(myCmykDarkRed)" : "Expected () but found 'currentColor icc-color(myCmykDarkRed)'.", + "icc-color(myCmykDarkRed) darkred" : "Expected end of value but found 'darkred'.", + "icc-color(myCmykDarkRed)" : "Expected () but found 'icc-color(myCmykDarkRed)'.", + "icc-color(myCmykDarkRed) inherit" : "Expected end of value but found 'inherit'.", + "inherit icc-color(myCmykDarkRed)" : "Expected end of value but found 'icc-color(myCmykDarkRed)'.", + "none inherit" : "Expected end of value but found 'inherit'." + } + })); + + suite.add(new ValidationTestCase({ + property: "fill-rule", + + valid: [ + "nonzero", + "evenodd", + "inherit" + ], + + invalid: { + "foo" : "Expected (nonzero | evenodd | inherit) but found 'foo'." + } + })); + ["flex", "-ms-flex", "-webkit-flex"].forEach(function(prop_name) { suite.add(new ValidationTestCase({ property: prop_name, @@ -894,11 +934,15 @@ property: "opacity", valid: [ + "0", + "0.5", "1" ], invalid: { - "foo" : "Expected ( | inherit) but found 'foo'." + "-0.75" : "Expected ( | inherit) but found '-0.75'.", + "12" : "Expected ( | inherit) but found '12'.", + "foo" : "Expected ( | inherit) but found 'foo'." } })); @@ -924,6 +968,75 @@ } })); + suite.add(new ValidationTestCase({ + property: "stroke-dasharray", + + valid: [ + "0", + "4", + "20px", + "20px 40px 30px", + "20px, 40px, 30px", + "none", + "inherit" + ], + + invalid: { + "-20px" : "Expected (none | | inherit) but found '-20px'.", + "auto" : "Expected (none | | inherit) but found 'auto'." + } + })); + + suite.add(new ValidationTestCase({ + property: "stroke-linecap", + + valid: [ + "butt", + "round", + "square", + "inherit" + ], + + invalid: { + "auto" : "Expected (butt | round | square | inherit) but found 'auto'.", + "none" : "Expected (butt | round | square | inherit) but found 'none'." + } + })); + + suite.add(new ValidationTestCase({ + property: "stroke-linejoin", + + valid: [ + "miter", + "round", + "bevel", + "inherit" + ], + + invalid: { + "auto" : "Expected (miter | round | bevel | inherit) but found 'auto'.", + "none" : "Expected (miter | round | bevel | inherit) but found 'none'." + } + })); + + suite.add(new ValidationTestCase({ + property: "stroke-miterlimit", + + valid: [ + "1", + "1.4", + "20", + "10", + "inherit" + ], + + invalid: { + "-10" : "Expected ( | inherit) but found '-10'.", + "0.5" : "Expected ( | inherit) but found '0.5'.", + "foo" : "Expected ( | inherit) but found 'foo'." + } + })); + suite.add(new ValidationTestCase({ property: "-ms-touch-action",