@conform-to/dom 1.15.0 → 1.16.0

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/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  ╚══════╝ ╚═════╝ ╚═╝ ╚══╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
8
8
  ```
9
9
 
10
- Version 1.15.0 / License MIT / Copyright (c) 2025 Edmund Hung
10
+ Version 1.16.0 / License MIT / Copyright (c) 2025 Edmund Hung
11
11
 
12
12
  Progressively enhance HTML forms with React. Build resilient, type-safe forms with no hassle using web standards.
13
13
 
package/dist/dom.js CHANGED
@@ -410,7 +410,6 @@ function normalizeFileValues(value) {
410
410
  * If the value or defaultValue is undefined, it will keep the current value instead
411
411
  */
412
412
  function updateField(element, options) {
413
- var _value$;
414
413
  var isChanged = false;
415
414
  if (isInputElement(element)) {
416
415
  switch (element.type) {
@@ -498,29 +497,32 @@ function updateField(element, options) {
498
497
  }
499
498
  var value = normalizeStringValues(options.value);
500
499
  var defaultValue = normalizeStringValues(options.defaultValue);
501
- var inputValue = (_value$ = value === null || value === void 0 ? void 0 : value[0]) !== null && _value$ !== void 0 ? _value$ : '';
502
- if (element.value !== inputValue) {
503
- /**
504
- * Triggering react custom change event
505
- * Solution based on dom-testing-library
506
- * @see https://github.com/facebook/react/issues/10135#issuecomment-401496776
507
- * @see https://github.com/testing-library/dom-testing-library/blob/main/src/events.js#L104-L123
508
- */
509
- var {
510
- set: valueSetter
511
- } = Object.getOwnPropertyDescriptor(element, 'value') || {};
512
- var prototype = Object.getPrototypeOf(element);
513
- var {
514
- set: prototypeValueSetter
515
- } = Object.getOwnPropertyDescriptor(prototype, 'value') || {};
516
- if (prototypeValueSetter && valueSetter !== prototypeValueSetter) {
517
- prototypeValueSetter.call(element, inputValue);
518
- } else if (valueSetter) {
519
- valueSetter.call(element, inputValue);
520
- } else {
521
- throw new Error('The given element does not have a value setter');
500
+ if (value) {
501
+ var _value$;
502
+ var inputValue = (_value$ = value[0]) !== null && _value$ !== void 0 ? _value$ : '';
503
+ if (element.value !== inputValue) {
504
+ /**
505
+ * Triggering react custom change event
506
+ * Solution based on dom-testing-library
507
+ * @see https://github.com/facebook/react/issues/10135#issuecomment-401496776
508
+ * @see https://github.com/testing-library/dom-testing-library/blob/main/src/events.js#L104-L123
509
+ */
510
+ var {
511
+ set: valueSetter
512
+ } = Object.getOwnPropertyDescriptor(element, 'value') || {};
513
+ var prototype = Object.getPrototypeOf(element);
514
+ var {
515
+ set: prototypeValueSetter
516
+ } = Object.getOwnPropertyDescriptor(prototype, 'value') || {};
517
+ if (prototypeValueSetter && valueSetter !== prototypeValueSetter) {
518
+ prototypeValueSetter.call(element, inputValue);
519
+ } else if (valueSetter) {
520
+ valueSetter.call(element, inputValue);
521
+ } else {
522
+ throw new Error('The given element does not have a value setter');
523
+ }
524
+ isChanged = true;
522
525
  }
523
- isChanged = true;
524
526
  }
525
527
  if (defaultValue) {
526
528
  var _defaultValue$;
package/dist/dom.mjs CHANGED
@@ -406,7 +406,6 @@ function normalizeFileValues(value) {
406
406
  * If the value or defaultValue is undefined, it will keep the current value instead
407
407
  */
408
408
  function updateField(element, options) {
409
- var _value$;
410
409
  var isChanged = false;
411
410
  if (isInputElement(element)) {
412
411
  switch (element.type) {
@@ -494,29 +493,32 @@ function updateField(element, options) {
494
493
  }
495
494
  var value = normalizeStringValues(options.value);
496
495
  var defaultValue = normalizeStringValues(options.defaultValue);
497
- var inputValue = (_value$ = value === null || value === void 0 ? void 0 : value[0]) !== null && _value$ !== void 0 ? _value$ : '';
498
- if (element.value !== inputValue) {
499
- /**
500
- * Triggering react custom change event
501
- * Solution based on dom-testing-library
502
- * @see https://github.com/facebook/react/issues/10135#issuecomment-401496776
503
- * @see https://github.com/testing-library/dom-testing-library/blob/main/src/events.js#L104-L123
504
- */
505
- var {
506
- set: valueSetter
507
- } = Object.getOwnPropertyDescriptor(element, 'value') || {};
508
- var prototype = Object.getPrototypeOf(element);
509
- var {
510
- set: prototypeValueSetter
511
- } = Object.getOwnPropertyDescriptor(prototype, 'value') || {};
512
- if (prototypeValueSetter && valueSetter !== prototypeValueSetter) {
513
- prototypeValueSetter.call(element, inputValue);
514
- } else if (valueSetter) {
515
- valueSetter.call(element, inputValue);
516
- } else {
517
- throw new Error('The given element does not have a value setter');
496
+ if (value) {
497
+ var _value$;
498
+ var inputValue = (_value$ = value[0]) !== null && _value$ !== void 0 ? _value$ : '';
499
+ if (element.value !== inputValue) {
500
+ /**
501
+ * Triggering react custom change event
502
+ * Solution based on dom-testing-library
503
+ * @see https://github.com/facebook/react/issues/10135#issuecomment-401496776
504
+ * @see https://github.com/testing-library/dom-testing-library/blob/main/src/events.js#L104-L123
505
+ */
506
+ var {
507
+ set: valueSetter
508
+ } = Object.getOwnPropertyDescriptor(element, 'value') || {};
509
+ var prototype = Object.getPrototypeOf(element);
510
+ var {
511
+ set: prototypeValueSetter
512
+ } = Object.getOwnPropertyDescriptor(prototype, 'value') || {};
513
+ if (prototypeValueSetter && valueSetter !== prototypeValueSetter) {
514
+ prototypeValueSetter.call(element, inputValue);
515
+ } else if (valueSetter) {
516
+ valueSetter.call(element, inputValue);
517
+ } else {
518
+ throw new Error('The given element does not have a value setter');
519
+ }
520
+ isChanged = true;
518
521
  }
519
- isChanged = true;
520
522
  }
521
523
  if (defaultValue) {
522
524
  var _defaultValue$;
@@ -98,7 +98,7 @@ function parse(payload, options) {
98
98
  return mergeResolveResult(result);
99
99
  }
100
100
  function createSubmission(context) {
101
- if (context.intent || !context.value || context.error) {
101
+ if (context.intent || context.error !== undefined) {
102
102
  return {
103
103
  status: !context.intent ? 'error' : undefined,
104
104
  payload: context.payload,
@@ -94,7 +94,7 @@ function parse(payload, options) {
94
94
  return mergeResolveResult(result);
95
95
  }
96
96
  function createSubmission(context) {
97
- if (context.intent || !context.value || context.error) {
97
+ if (context.intent || context.error !== undefined) {
98
98
  return {
99
99
  status: !context.intent ? 'error' : undefined,
100
100
  payload: context.payload,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A set of opinionated helpers built on top of the Constraint Validation API",
4
4
  "homepage": "https://conform.guide",
5
5
  "license": "MIT",
6
- "version": "1.15.0",
6
+ "version": "1.16.0",
7
7
  "main": "./dist/index.js",
8
8
  "module": "./dist/index.mjs",
9
9
  "types": "./dist/index.d.ts",