@schukai/monster 4.46.3 → 4.46.4

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
 
4
4
 
5
+ ## [4.46.4] - 2025-11-19
6
+
7
+ ### Bug Fixes
8
+
9
+ - Fix option parsing: correctly convert numeric attributes when default is Infinity
10
+
11
+
12
+
5
13
  ## [4.46.3] - 2025-11-19
6
14
 
7
15
  ### Bug Fixes
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.46.3"}
1
+ {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.46.4"}
@@ -14,12 +14,13 @@
14
14
 
15
15
  import { Pathfinder } from "../../data/pathfinder.mjs";
16
16
  import {
17
- isBoolean,
18
- isString,
19
- isObject,
20
- isArray,
21
- isFunction,
22
- isInteger,
17
+ isBoolean,
18
+ isString,
19
+ isObject,
20
+ isNumber,
21
+ isArray,
22
+ isFunction,
23
+ isInteger,
23
24
  } from "../../types/is.mjs";
24
25
  import { extractKeys } from "./extract-keys.mjs";
25
26
 
@@ -58,60 +59,62 @@ export { initOptionsFromAttributes };
58
59
  * @this HTMLElement - The context of the DOM element.
59
60
  */
60
61
  function initOptionsFromAttributes(
61
- element,
62
- options,
63
- mapping = {},
64
- prefix = "data-monster-option-",
62
+ element,
63
+ options,
64
+ mapping = {},
65
+ prefix = "data-monster-option-",
65
66
  ) {
66
- if (!(element instanceof HTMLElement)) return options;
67
- if (!element.hasAttributes()) return options;
67
+ if (!(element instanceof HTMLElement)) return options;
68
+ if (!element.hasAttributes()) return options;
68
69
 
69
- const keyMap = extractKeys(options);
70
- const finder = new Pathfinder(options);
70
+ const keyMap = extractKeys(options);
71
+ const finder = new Pathfinder(options);
71
72
 
72
- element.getAttributeNames().forEach((name) => {
73
- if (!name.startsWith(prefix)) return;
73
+ element.getAttributeNames().forEach((name) => {
74
+ if (!name.startsWith(prefix)) return;
74
75
 
75
- // check if the attribute name is a valid option.
76
- // the mapping between the attribute is simple. The dash is replaced by a dot.
77
- // e.g. data-monster-url => url
78
- const optionName = keyMap.get(name.substring(prefix.length).toLowerCase());
79
- if (!finder.exists(optionName)) return;
76
+ // check if the attribute name is a valid option.
77
+ // the mapping between the attribute is simple. The dash is replaced by a dot.
78
+ // e.g. data-monster-url => url
79
+ const optionName = keyMap.get(name.substring(prefix.length).toLowerCase());
80
+ if (!finder.exists(optionName)) return;
80
81
 
81
- if (element.hasAttribute(name)) {
82
- let value = element.getAttribute(name);
83
- if (
84
- mapping.hasOwnProperty(optionName) &&
85
- isFunction(mapping[optionName])
86
- ) {
87
- value = mapping[optionName](value);
88
- }
82
+ if (element.hasAttribute(name)) {
83
+ let value = element.getAttribute(name);
84
+ if (
85
+ mapping.hasOwnProperty(optionName) &&
86
+ isFunction(mapping[optionName])
87
+ ) {
88
+ value = mapping[optionName](value);
89
+ }
89
90
 
90
- let optionValue = finder.getVia(optionName);
91
- if (optionValue === null || optionValue === undefined) {
92
- optionValue = value;
93
- }
91
+ let optionValue = finder.getVia(optionName);
92
+ if (optionValue === null || optionValue === undefined) {
93
+ optionValue = value;
94
+ }
94
95
 
95
- //const typeOfOptionValue = typeof optionValue;
96
- if (optionValue === null || optionValue === undefined) {
97
- value = null;
98
- } else if (isBoolean(optionValue)) {
99
- value = value === "true";
100
- } else if (isInteger(optionValue)) {
101
- value = Number(value);
102
- } else if (isString(optionValue)) {
103
- value = String(value);
104
- } else if (isObject(optionValue)) {
105
- value = JSON.parse(value);
106
- } else if (isArray(optionValue)) {
107
- value = value.split("::");
108
- } else {
109
- value = optionValue;
110
- }
96
+ //const typeOfOptionValue = typeof optionValue;
97
+ if (optionValue === null || optionValue === undefined) {
98
+ value = null;
99
+ } else if (isBoolean(optionValue)) {
100
+ value = value === "true";
101
+ } else if (isInteger(optionValue)) {
102
+ value = Number(value);
103
+ } else if (isNumber(optionValue)) {
104
+ value = Number(value);
105
+ } else if (isString(optionValue)) {
106
+ value = String(value);
107
+ } else if (isObject(optionValue)) {
108
+ value = JSON.parse(value);
109
+ } else if (isArray(optionValue)) {
110
+ value = value.split("::");
111
+ } else {
112
+ value = optionValue;
113
+ }
111
114
 
112
- finder.setVia(optionName, value);
113
- }
114
- });
115
+ finder.setVia(optionName, value);
116
+ }
117
+ });
115
118
 
116
- return options;
119
+ return options;
117
120
  }
@@ -15,18 +15,19 @@
15
15
  import { proxyInstanceMarker } from "../constants.mjs";
16
16
 
17
17
  export {
18
- isIterable,
19
- isPrimitive,
20
- isSymbol,
21
- isBoolean,
22
- isString,
23
- isObject,
24
- isInstance,
25
- isArray,
26
- isFunction,
27
- isInteger,
28
- isProxy,
29
- isElement,
18
+ isIterable,
19
+ isPrimitive,
20
+ isSymbol,
21
+ isBoolean,
22
+ isString,
23
+ isObject,
24
+ isInstance,
25
+ isArray,
26
+ isFunction,
27
+ isInteger,
28
+ isNumber,
29
+ isProxy,
30
+ isElement,
30
31
  };
31
32
 
32
33
  /**
@@ -35,7 +36,7 @@ export {
35
36
  * @returns {boolean}
36
37
  */
37
38
  function isElement(value) {
38
- return value instanceof Element;
39
+ return value instanceof Element;
39
40
  }
40
41
 
41
42
  /**
@@ -45,7 +46,7 @@ function isElement(value) {
45
46
  * @returns {boolean}
46
47
  */
47
48
  function isProxy(value) {
48
- return value?.[proxyInstanceMarker] === proxyInstanceMarker;
49
+ return value?.[proxyInstanceMarker] === proxyInstanceMarker;
49
50
  }
50
51
 
51
52
  /**
@@ -63,9 +64,9 @@ function isProxy(value) {
63
64
  * @copyright schukai GmbH
64
65
  */
65
66
  function isIterable(value) {
66
- if (value === undefined) return false;
67
- if (value === null) return false;
68
- return typeof value?.[Symbol.iterator] === "function";
67
+ if (value === undefined) return false;
68
+ if (value === null) return false;
69
+ return typeof value?.[Symbol.iterator] === "function";
69
70
  }
70
71
 
71
72
  /**
@@ -81,24 +82,24 @@ function isIterable(value) {
81
82
  * @copyright schukai GmbH
82
83
  */
83
84
  function isPrimitive(value) {
84
- var type;
85
+ var type;
85
86
 
86
- if (value === undefined || value === null) {
87
- return true;
88
- }
87
+ if (value === undefined || value === null) {
88
+ return true;
89
+ }
89
90
 
90
- type = typeof value;
91
+ type = typeof value;
91
92
 
92
- if (
93
- type === "string" ||
94
- type === "number" ||
95
- type === "boolean" ||
96
- type === "symbol"
97
- ) {
98
- return true;
99
- }
93
+ if (
94
+ type === "string" ||
95
+ type === "number" ||
96
+ type === "boolean" ||
97
+ type === "symbol"
98
+ ) {
99
+ return true;
100
+ }
100
101
 
101
- return false;
102
+ return false;
102
103
  }
103
104
 
104
105
  /**
@@ -114,7 +115,7 @@ function isPrimitive(value) {
114
115
  * @copyright schukai GmbH
115
116
  */
116
117
  function isSymbol(value) {
117
- return "symbol" === typeof value ? true : false;
118
+ return "symbol" === typeof value ? true : false;
118
119
  }
119
120
 
120
121
  /**
@@ -130,11 +131,11 @@ function isSymbol(value) {
130
131
  * @copyright schukai GmbH
131
132
  */
132
133
  function isBoolean(value) {
133
- if (value === true || value === false) {
134
- return true;
135
- }
134
+ if (value === true || value === false) {
135
+ return true;
136
+ }
136
137
 
137
- return false;
138
+ return false;
138
139
  }
139
140
 
140
141
  /**
@@ -150,10 +151,10 @@ function isBoolean(value) {
150
151
  * @copyright schukai GmbH
151
152
  */
152
153
  function isString(value) {
153
- if (value === undefined || typeof value !== "string") {
154
- return false;
155
- }
156
- return true;
154
+ if (value === undefined || typeof value !== "string") {
155
+ return false;
156
+ }
157
+ return true;
157
158
  }
158
159
 
159
160
  /**
@@ -169,14 +170,14 @@ function isString(value) {
169
170
  * @copyright schukai GmbH
170
171
  */
171
172
  function isObject(value) {
172
- if (isArray(value)) return false;
173
- if (isPrimitive(value)) return false;
173
+ if (isArray(value)) return false;
174
+ if (isPrimitive(value)) return false;
174
175
 
175
- if (typeof value === "object") {
176
- return true;
177
- }
176
+ if (typeof value === "object") {
177
+ return true;
178
+ }
178
179
 
179
- return false;
180
+ return false;
180
181
  }
181
182
 
182
183
  /**
@@ -193,18 +194,18 @@ function isObject(value) {
193
194
  * @copyright schukai GmbH
194
195
  */
195
196
  function isInstance(value, instance) {
196
- if (!isObject(value)) return false;
197
- if (!isFunction(instance)) return false;
198
- if (!instance.hasOwnProperty("prototype")) return false;
199
- if (value instanceof instance) return true;
197
+ if (!isObject(value)) return false;
198
+ if (!isFunction(instance)) return false;
199
+ if (!instance.hasOwnProperty("prototype")) return false;
200
+ if (value instanceof instance) return true;
200
201
 
201
- let proto = Object.getPrototypeOf(value);
202
- while (proto != null) {
203
- if (proto === instance.prototype) return true;
204
- proto = Object.getPrototypeOf(proto);
205
- }
202
+ let proto = Object.getPrototypeOf(value);
203
+ while (proto != null) {
204
+ if (proto === instance.prototype) return true;
205
+ proto = Object.getPrototypeOf(proto);
206
+ }
206
207
 
207
- return false;
208
+ return false;
208
209
  }
209
210
 
210
211
  /**
@@ -221,7 +222,7 @@ function isInstance(value, instance) {
221
222
  * @see https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
222
223
  */
223
224
  function isArray(value) {
224
- return Array.isArray(value);
225
+ return Array.isArray(value);
225
226
  }
226
227
 
227
228
  /**
@@ -237,14 +238,31 @@ function isArray(value) {
237
238
  * @copyright schukai GmbH
238
239
  */
239
240
  function isFunction(value) {
240
- if (isArray(value)) return false;
241
- if (isPrimitive(value)) return false;
241
+ if (isArray(value)) return false;
242
+ if (isPrimitive(value)) return false;
242
243
 
243
- if (typeof value === "function") {
244
- return true;
245
- }
244
+ if (typeof value === "function") {
245
+ return true;
246
+ }
246
247
 
247
- return false;
248
+ return false;
249
+ }
250
+
251
+ /**
252
+ * Cechs whether the value passed is a number.
253
+ *
254
+ * This method is used in the library to have consistent names.
255
+ *
256
+ * @externalExample ../../example/types/is-number.mjs
257
+ *
258
+ * @param {*} value
259
+ * @return {boolean}
260
+ *
261
+ * @license AGPLv3
262
+ * @since 4.47.0
263
+ */
264
+ function isNumber(value) {
265
+ return typeof value === "number" && !isNaN(value);
248
266
  }
249
267
 
250
268
  /**
@@ -260,5 +278,5 @@ function isFunction(value) {
260
278
  * @copyright schukai GmbH
261
279
  */
262
280
  function isInteger(value) {
263
- return Number.isInteger(value);
281
+ return Number.isInteger(value);
264
282
  }