Make sure falsy values are preserved

This commit is contained in:
2026-02-20 09:20:35 +01:00
parent f34c764391
commit 3c70db24a2

View File

@@ -324,8 +324,8 @@ class TpForm extends LitElement {
reset() { reset() {
for (let i = 0, li = this._origValues.length; i < li; ++i) { for (let i = 0, li = this._origValues.length; i < li; ++i) {
const item = this._origValues[i]; const item = this._origValues[i];
item.control.value = this._copyValue(item.value || null, item.control); item.control.value = this._copyValue(item.value ?? null, item.control);
item.control.checked = this._copyValue(item.checked || null, item.control); item.control.checked = this._copyValue(item.checked ?? null, item.control);
if (typeof item.control.reset === 'function') { if (typeof item.control.reset === 'function') {
item.control.reset(); item.control.reset();
} }
@@ -445,7 +445,7 @@ class TpForm extends LitElement {
_copyValue(value, control) { _copyValue(value, control) {
if (control.defaultValue !== undefined || control.hasAttribute('default-value')) { if (control.defaultValue !== undefined || control.hasAttribute('default-value')) {
value = control.defaultValue || control.getAttribute('default-value'); value = control.defaultValue ?? control.getAttribute('default-value');
} }
return clone(value); return clone(value);