@schukai/monster 4.48.2 → 4.48.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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
 
4
4
 
5
+ ## [4.48.3] - 2025-12-02
6
+
7
+ ### Bug Fixes
8
+
9
+ - **select:** prevent NaN labels
10
+
11
+
12
+
5
13
  ## [4.48.2] - 2025-12-02
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.48.2"}
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.48.3"}
@@ -1909,7 +1909,8 @@ function buildSelectionLabel(value) {
1909
1909
  */
1910
1910
  async function lookupValueAndCache(value) {
1911
1911
  const lookupUrl = this.getOption("lookup.url");
1912
- if (!lookupUrl || !value) {
1912
+ // A more robust check for invalid values. 0 and "" are valid.
1913
+ if (!lookupUrl || value === null || value === undefined || Number.isNaN(value)) {
1913
1914
  return;
1914
1915
  }
1915
1916
 
@@ -1938,6 +1939,17 @@ async function lookupValueAndCache(value) {
1938
1939
 
1939
1940
  let found = false;
1940
1941
  for (const [itemValue, itemLabel] of map.entries()) {
1942
+ // If the label template results in NaN, log an error and skip caching.
1943
+ if (itemLabel === "NaN") {
1944
+ addErrorAttribute(
1945
+ this,
1946
+ new Error(
1947
+ `Lookup for value '${itemValue}' resulted in a 'NaN' label. Check 'mapping.labelTemplate' and API response.`,
1948
+ ),
1949
+ );
1950
+ continue;
1951
+ }
1952
+
1941
1953
  // The lookup might return more than the requested value, so we cache all of them.
1942
1954
  if (!this[lookupCacheSymbol].has(itemValue)) {
1943
1955
  this[lookupCacheSymbol].set(itemValue, itemLabel);
@@ -1971,8 +1983,10 @@ function getSelectionLabel(value) {
1971
1983
  if (isString(label)) return label;
1972
1984
  }
1973
1985
 
1974
- // If the label was not found, and we have a lookup URL, trigger a lookup.
1975
- if (this.getOption("lookup.url")) {
1986
+ // If the label was not found, and we have a lookup URL, trigger a lookup for valid values.
1987
+ const isValueValidForLookup =
1988
+ value !== null && value !== undefined && !Number.isNaN(value);
1989
+ if (this.getOption("lookup.url") && isValueValidForLookup) {
1976
1990
  lookupValueAndCache.call(this, value).catch((e) => {
1977
1991
  addErrorAttribute(this, e);
1978
1992
  });