@jsenv/dom 0.5.2 → 0.5.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/dist/jsenv_dom.js CHANGED
@@ -418,20 +418,15 @@ const normalizeNumber = (value, context, unit, propertyName) => {
418
418
  return value;
419
419
  }
420
420
  if (typeof value === "string") {
421
- if (value === "auto") {
422
- return "auto";
423
- }
424
- if (value === "none") {
425
- return "none";
426
- }
427
- const numericValue = parseFloat(value);
428
- if (isNaN(numericValue)) {
429
- console.warn(
430
- `"${propertyName}": ${value} cannot be converted to number, returning value as-is.`,
431
- );
432
- return value;
421
+ // For js context, only convert px values to numbers
422
+ if (unit === "px" && value.endsWith("px")) {
423
+ const numericValue = parseFloat(value);
424
+ if (!isNaN(numericValue)) {
425
+ return numericValue;
426
+ }
433
427
  }
434
- return numericValue;
428
+ // Keep all other strings as-is (including %, em, rem, auto, none, etc.)
429
+ return value;
435
430
  }
436
431
  return value;
437
432
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/dom",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "DOM utilities for writing frontend code",
5
5
  "repository": {
6
6
  "type": "git",
@@ -136,20 +136,15 @@ const normalizeNumber = (value, context, unit, propertyName) => {
136
136
  return value;
137
137
  }
138
138
  if (typeof value === "string") {
139
- if (value === "auto") {
140
- return "auto";
141
- }
142
- if (value === "none") {
143
- return "none";
144
- }
145
- const numericValue = parseFloat(value);
146
- if (isNaN(numericValue)) {
147
- console.warn(
148
- `"${propertyName}": ${value} cannot be converted to number, returning value as-is.`,
149
- );
150
- return value;
139
+ // For js context, only convert px values to numbers
140
+ if (unit === "px" && value.endsWith("px")) {
141
+ const numericValue = parseFloat(value);
142
+ if (!isNaN(numericValue)) {
143
+ return numericValue;
144
+ }
151
145
  }
152
- return numericValue;
146
+ // Keep all other strings as-is (including %, em, rem, auto, none, etc.)
147
+ return value;
153
148
  }
154
149
  return value;
155
150
  };