From 602c1604a83e738cf6a5bd317edd0ef21f747c5b Mon Sep 17 00:00:00 2001
From: Volker Schukai <volker.schukai@schukai.com>
Date: Tue, 28 Mar 2023 11:28:35 +0200
Subject: [PATCH] fix: Updated regex to capture the negative sign

---
 application/source/dom/dimension.mjs     |  3 +--
 development/test/cases/dom/dimension.mjs | 11 ++++++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/application/source/dom/dimension.mjs b/application/source/dom/dimension.mjs
index e8fdb5e5e..5148e754d 100644
--- a/application/source/dom/dimension.mjs
+++ b/application/source/dom/dimension.mjs
@@ -74,7 +74,7 @@ function getDeviceDPI() {
  */
 
 function convertToPixels(value, parentElement = document.documentElement, fontSizeElement = document.documentElement) {
-    const regex = /^([\d.]+)(.*)$/;
+    const regex = /^(-?[\d.]+)(.*)$/;
     const matchResult = value.match(regex);
 
     if (!matchResult) {
@@ -82,7 +82,6 @@ function convertToPixels(value, parentElement = document.documentElement, fontSi
     }
 
     const [, num, unit] = matchResult;
-    
     const number = parseFloat(num);
     const dpi = getDeviceDPI();
 
diff --git a/development/test/cases/dom/dimension.mjs b/development/test/cases/dom/dimension.mjs
index 6cf31dd23..5ca418e28 100644
--- a/development/test/cases/dom/dimension.mjs
+++ b/development/test/cases/dom/dimension.mjs
@@ -69,7 +69,16 @@ describe('dimension', () => {
             };
 
             expect(errorFn).to.throw(Error, `Invalid value format: ${invalidValue}`);
-        });        
+        });
+
+        it("should handle negative values correctly", () => {
+            const negativeValue = "-10px";
+            const expectedResult = -10;
+
+            const result = convertToPixels(negativeValue);
+
+            expect(result).to.equal(expectedResult);
+        });
 
         it('should correctly convert em values', () => {
             const testElement = document.createElement('div');
-- 
GitLab