From 3c70db24a23f6332bcef3940c87d2537a9a50a79 Mon Sep 17 00:00:00 2001 From: pk Date: Fri, 20 Feb 2026 09:20:35 +0100 Subject: [PATCH] Make sure falsy values are preserved --- tp-form.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tp-form.js b/tp-form.js index 5adf09f..e5c67f1 100644 --- a/tp-form.js +++ b/tp-form.js @@ -324,8 +324,8 @@ class TpForm extends LitElement { reset() { for (let i = 0, li = this._origValues.length; i < li; ++i) { const item = this._origValues[i]; - item.control.value = this._copyValue(item.value || null, item.control); - item.control.checked = this._copyValue(item.checked || null, item.control); + item.control.value = this._copyValue(item.value ?? null, item.control); + item.control.checked = this._copyValue(item.checked ?? null, item.control); if (typeof item.control.reset === 'function') { item.control.reset(); } @@ -445,7 +445,7 @@ class TpForm extends LitElement { _copyValue(value, control) { 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);