@schukai/monster 3.35.1 → 3.35.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/source/dom/dimension.mjs
CHANGED
@@ -74,7 +74,7 @@ function getDeviceDPI() {
|
|
74
74
|
*/
|
75
75
|
|
76
76
|
function convertToPixels(value, parentElement = document.documentElement, fontSizeElement = document.documentElement) {
|
77
|
-
const regex = /^([\d.]+)(.*)$/;
|
77
|
+
const regex = /^(-?[\d.]+)(.*)$/;
|
78
78
|
const matchResult = value.match(regex);
|
79
79
|
|
80
80
|
if (!matchResult) {
|
@@ -82,7 +82,6 @@ function convertToPixels(value, parentElement = document.documentElement, fontSi
|
|
82
82
|
}
|
83
83
|
|
84
84
|
const [, num, unit] = matchResult;
|
85
|
-
|
86
85
|
const number = parseFloat(num);
|
87
86
|
const dpi = getDeviceDPI();
|
88
87
|
|
package/source/types/version.mjs
CHANGED
@@ -69,7 +69,16 @@ describe('dimension', () => {
|
|
69
69
|
};
|
70
70
|
|
71
71
|
expect(errorFn).to.throw(Error, `Invalid value format: ${invalidValue}`);
|
72
|
-
});
|
72
|
+
});
|
73
|
+
|
74
|
+
it("should handle negative values correctly", () => {
|
75
|
+
const negativeValue = "-10px";
|
76
|
+
const expectedResult = -10;
|
77
|
+
|
78
|
+
const result = convertToPixels(negativeValue);
|
79
|
+
|
80
|
+
expect(result).to.equal(expectedResult);
|
81
|
+
});
|
73
82
|
|
74
83
|
it('should correctly convert em values', () => {
|
75
84
|
const testElement = document.createElement('div');
|
package/test/cases/monster.mjs
CHANGED