Repository: jsdom/cssstyle (js)

Issue:
Negative values invalid for `marginBottom`?
I see `restrictToPositive` is set to true for `marginBottom` (and the tests assert that the value cannot be negative) - is this correct?

https://github.com/jsdom/cssstyle/blob/ba349623a94d5d1fc6527c770e6684acc82bac44/lib/properties/marginBottom.js#L6

https://github.com/jsdom/cssstyle/blob/ba349623a94d5d1fc6527c770e6684acc82bac44/lib/parsers.js#L230

https://github.com/jsdom/cssstyle/blob/ba349623a94d5d1fc6527c770e6684acc82bac44/test/properties.test.js#L815-L817

I understood that its value can be positive, zero, or negative (see [https://developer.mozilla.org/en-US/docs/Web/CSS/margin-bottom](https://developer.mozilla.org/en-US/docs/Web/CSS/margin-bottom#:~:text=Its%20value%20can%20be%20positive%2C%20zero%2C%20or%20negative)).

Pull request description:
Fix margin handlers
Fix #222

Patch:
diff --git a/lib/properties/margin.js b/lib/properties/margin.js
index 61c5390..61f9cc7 100644
--- a/lib/properties/margin.js
+++ b/lib/properties/margin.js
@@ -5,7 +5,7 @@ const parsers = require("../parsers");
 const positions = ["top", "right", "bottom", "left"];
 
 module.exports.parse = function parse(v) {
-  const val = parsers.parseMeasurement(v, true);
+  const val = parsers.parseMeasurement(v);
   if (val) {
     return val;
   }
diff --git a/lib/properties/marginBottom.js b/lib/properties/marginBottom.js
index 95a296a..8e276d5 100644
--- a/lib/properties/marginBottom.js
+++ b/lib/properties/marginBottom.js
@@ -3,7 +3,7 @@
 const parsers = require("../parsers");
 
 module.exports.parse = function parse(v) {
-  const val = parsers.parseMeasurement(v, true);
+  const val = parsers.parseMeasurement(v);
   if (val) {
     return val;
   }
diff --git a/lib/properties/marginLeft.js b/lib/properties/marginLeft.js
index 53d4850..f50a2be 100644
--- a/lib/properties/marginLeft.js
+++ b/lib/properties/marginLeft.js
@@ -3,7 +3,7 @@
 const parsers = require("../parsers");
 
 module.exports.parse = function parse(v) {
-  const val = parsers.parseMeasurement(v, true);
+  const val = parsers.parseMeasurement(v);
   if (val) {
     return val;
   }
diff --git a/lib/properties/marginRight.js b/lib/properties/marginRight.js
index 98bfd01..b1de351 100644
--- a/lib/properties/marginRight.js
+++ b/lib/properties/marginRight.js
@@ -3,7 +3,7 @@
 const parsers = require("../parsers");
 
 module.exports.parse = function parse(v) {
-  const val = parsers.parseMeasurement(v, true);
+  const val = parsers.parseMeasurement(v);
   if (val) {
     return val;
   }
diff --git a/lib/properties/marginTop.js b/lib/properties/marginTop.js
index e5303c9..b6d73a7 100644
--- a/lib/properties/marginTop.js
+++ b/lib/properties/marginTop.js
@@ -3,7 +3,7 @@
 const parsers = require("../parsers");
 
 module.exports.parse = function parse(v) {
-  const val = parsers.parseMeasurement(v, true);
+  const val = parsers.parseMeasurement(v);
   if (val) {
     return val;
   }


Test patch:
diff --git a/test/properties.test.js b/test/properties.test.js
index 88855f5..23d9b6d 100644
--- a/test/properties.test.js
+++ b/test/properties.test.js
@@ -764,16 +764,16 @@ describe("box model", () => {
     testPropertyValue("margin-top", "10px", "10px");
   });
 
-  it("margin-top should not set / get negative length", () => {
-    testPropertyValue("margin-top", "-10px", "");
+  it("margin-top should set / get negative length", () => {
+    testPropertyValue("margin-top", "-10px", "-10px");
   });
 
   it("margin-top should set / get percent", () => {
     testPropertyValue("margin-top", "10%", "10%");
   });
 
-  it("margin-top should not set / get negative percent", () => {
-    testPropertyValue("margin-top", "-10%", "");
+  it("margin-top should set / get negative percent", () => {
+    testPropertyValue("margin-top", "-10%", "-10%");
   });
 
   it("margin-right should set / get keyword", () => {
@@ -788,16 +788,16 @@ describe("box model", () => {
     testPropertyValue("margin-right", "10px", "10px");
   });
 
-  it("margin-right should not set / get negative length", () => {
-    testPropertyValue("margin-right", "-10px", "");
+  it("margin-right should set / get negative length", () => {
+    testPropertyValue("margin-right", "-10px", "-10px");
   });
 
   it("margin-right should set / get percent", () => {
     testPropertyValue("margin-right", "10%", "10%");
   });
 
-  it("margin-right should not set / get negative percent", () => {
-    testPropertyValue("margin-right", "-10%", "");
+  it("margin-right should set / get negative percent", () => {
+    testPropertyValue("margin-right", "-10%", "-10%");
   });
 
   it("margin-bottom should set / get keyword", () => {
@@ -812,16 +812,16 @@ describe("box model", () => {
     testPropertyValue("margin-bottom", "10px", "10px");
   });
 
-  it("margin-bottom should not set / get negative length", () => {
-    testPropertyValue("margin-bottom", "-10px", "");
+  it("margin-bottom should set / get negative length", () => {
+    testPropertyValue("margin-bottom", "-10px", "-10px");
   });
 
   it("margin-bottom should set / get percent", () => {
     testPropertyValue("margin-bottom", "10%", "10%");
   });
 
-  it("margin-bottom should not set / get negative percent", () => {
-    testPropertyValue("margin-bottom", "-10%", "");
+  it("margin-bottom should set / get negative percent", () => {
+    testPropertyValue("margin-bottom", "-10%", "-10%");
   });
 
   it("margin-left should set / get keyword", () => {
@@ -836,16 +836,16 @@ describe("box model", () => {
     testPropertyValue("margin-left", "10px", "10px");
   });
 
-  it("margin-left should not set / get negative length", () => {
-    testPropertyValue("margin-left", "-10px", "");
+  it("margin-left should set / get negative length", () => {
+    testPropertyValue("margin-left", "-10px", "-10px");
   });
 
   it("margin-left should set / get percent", () => {
     testPropertyValue("margin-left", "10%", "10%");
   });
 
-  it("margin-left should not set / get negative percent", () => {
-    testPropertyValue("margin-left", "-10%", "");
+  it("margin-left should set / get negative percent", () => {
+    testPropertyValue("margin-left", "-10%", "-10%");
   });
 
   it("margin shorthand should set / get keyword", () => {