Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • oss/libraries/javascript/monster
1 result
Select Git revision
Loading items
Show changes
Commits on Source (4)
<a name="v3.35.1"></a>
## [v3.35.1] - 2023-03-28
### Bug Fixes
- invalid input throws TypeError
<a name="v3.35.0"></a>
## [v3.35.0] - 2023-03-27
### Changes
......@@ -497,6 +503,7 @@
<a name="1.8.0"></a>
## 1.8.0 - 2021-08-15
[v3.35.1]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.35.0...v3.35.1
[v3.35.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.34.0...v3.35.0
[v3.34.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.33.0...v3.34.0
[v3.33.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.32.0...v3.33.0
......
{
"name": "@schukai/monster",
"version": "3.34.0",
"version": "3.35.0",
"description": "Monster is a simple library for creating fast, robust and lightweight websites.",
"keywords": [
"framework",
......
......@@ -70,11 +70,19 @@ function getDeviceDPI() {
* @copyright schukai GmbH
* @throws {Error} Unsupported unit
* @memberOf Monster.DOM
* @throws {Error} Invalid value format
*/
function convertToPixels(value, parentElement = document.documentElement, fontSizeElement = document.documentElement) {
const regex = /^([\d.]+)(.*)$/;
const [, num, unit] = value.match(regex);
const matchResult = value.match(regex);
if (!matchResult) {
throw new Error(`Invalid value format: ${value}`);
}
const [, num, unit] = matchResult;
const number = parseFloat(num);
const dpi = getDeviceDPI();
......
......@@ -142,7 +142,7 @@ function getMonsterVersion() {
}
/** don't touch, replaced by make with package.json version */
monsterVersion = new Version("3.34.0");
monsterVersion = new Version("3.35.0");
return monsterVersion;
}
{
"name": "monster",
"version": "3.34.0",
"version": "3.35.0",
"description": "monster",
"repository": {
"type": "git",
......
......@@ -61,6 +61,16 @@ describe('dimension', () => {
expect(result).to.equal(100);
});
it("should throw an error when the input value has an invalid format", () => {
const invalidValue = "invalid_value";
const errorFn = () => {
convertToPixels(invalidValue);
};
expect(errorFn).to.throw(Error, `Invalid value format: ${invalidValue}`);
});
it('should correctly convert em values', () => {
const testElement = document.createElement('div');
testElement.style.fontSize = '16px';
......
......@@ -7,7 +7,7 @@ describe('Monster', function () {
let monsterVersion
/** don´t touch, replaced by make with package.json version */
monsterVersion = new Version("3.34.0")
monsterVersion = new Version("3.35.0")
let m = getMonsterVersion();
......
{"version":"3.35.0"}
{"version":"3.35.1"}