diff --git a/lib/properties/borderSpacing.js b/lib/properties/borderSpacing.js index ec72477b..a77b7434 100644 --- a/lib/properties/borderSpacing.js +++ b/lib/properties/borderSpacing.js @@ -39,16 +39,19 @@ function parse(v) { switch (value.length) { case 1: { return parsers.resolveNumericValue(value, { - type: "length" + type: "length", + min: 0 }); } case 2: { const [part1, part2] = value; const val1 = parsers.resolveNumericValue([part1], { - type: "length" + type: "length", + min: 0 }); const val2 = parsers.resolveNumericValue([part2], { - type: "length" + type: "length", + min: 0 }); if (val1 && val2) { return `${val1} ${val2}`; diff --git a/test/properties.test.js b/test/properties.test.js index da9a45f3..f21dd674 100644 --- a/test/properties.test.js +++ b/test/properties.test.js @@ -771,6 +771,18 @@ describe("border", () => { testPropertyValue("border-spacing", "10px 20px", "10px 20px"); }); + it("border-spacing should not set / get negative length", () => { + testPropertyValue("border-spacing", "-10px", ""); + }); + + it("border-spacing should not set / get negative length as the first of two values", () => { + testPropertyValue("border-spacing", "-10px 20px", ""); + }); + + it("border-spacing should not set / get negative length as the second of two values", () => { + testPropertyValue("border-spacing", "10px -20px", ""); + }); + it("border-top shorthand should set / get value", () => { testImplicitPropertyValue( "border-top",